@restregular/dsh-memory 0.13.2 → 0.14.1
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 +14 -0
- package/lib/client.js +823 -18
- package/lib/inject/apply.js +74 -6
- package/lib/inject/audit-types.js +6 -0
- package/lib/inject/signals.js +8 -0
- package/lib/panel.js +62 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -434,6 +434,49 @@ window.__ModuleLoader__.load({
|
|
|
434
434
|
'.memp .audit-tip-content{font-size:11px;line-height:1.55;white-space:pre-wrap;word-break:break-word;color:var(--dsw-alias-label-primary);max-height:none;overflow:visible}',
|
|
435
435
|
'.memp .audit-tip-foot{margin-top:6px;font-size:9.5px;color:var(--dsw-alias-label-secondary)}',
|
|
436
436
|
'.memp .rec.focus{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 1px color-mix(in srgb,var(--dsw-alias-brand-primary) 25%,transparent)}',
|
|
437
|
+
// 审计 → 轨迹的精准跳转按钮:只在有锚点时出现,不抢详情头部的主操作。
|
|
438
|
+
'.memp .audit-jump{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--dsw-alias-border-l1);border-radius:7px;padding:2px 7px;font-size:10.5px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);cursor:pointer}',
|
|
439
|
+
'.memp .audit-jump:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}',
|
|
440
|
+
'.memp .audit-jump[disabled]{opacity:.55;cursor:default}',
|
|
441
|
+
'.memp .audit-jump-note{font-size:10px;color:var(--dsw-alias-label-secondary)}',
|
|
442
|
+
// 会话视图里的「记忆审计」页:壳层已经有自己的滚动区,这里只负责头部。
|
|
443
|
+
'.mem-view{display:flex;flex-direction:column;gap:10px;padding:12px 14px 6px;min-height:0;height:100%;box-sizing:border-box;overflow:hidden;color:var(--dsw-alias-label-primary)}',
|
|
444
|
+
'.mem-view-head{display:flex;align-items:center;gap:9px;flex-wrap:wrap;flex:none}',
|
|
445
|
+
'.mem-view-head b{font-size:14px}',
|
|
446
|
+
'.mem-view-head .muted{font-size:11.5px;color:var(--dsw-alias-label-secondary)}',
|
|
447
|
+
'.mem-view-head .spacer{flex:1}',
|
|
448
|
+
// 记忆视图自己占满 viewArea,并声明 composer overlay:壳层会把 viewArea
|
|
449
|
+
// 压成 flex:1 1 0 / min-height:0,滚动只发生在审计列表里,外层不再跟着滚。
|
|
450
|
+
'.mem-view{display:flex;flex-direction:column;gap:10px;padding:12px 14px calc(var(--dsh-composer-height,152px) + 14px);min-height:0;height:100%;box-sizing:border-box;overflow:hidden;color:var(--dsw-alias-label-primary)}',
|
|
451
|
+
'.mem-view-body{min-height:0;flex:1;display:flex;flex-direction:column;overflow:hidden}',
|
|
452
|
+
'.mem-view .audit{height:100%;max-height:none;min-height:0;flex:1;overflow:hidden}',
|
|
453
|
+
'.mem-view .audit-split{min-height:0}',
|
|
454
|
+
'.mem-view .audit-detail{max-height:100%}',
|
|
455
|
+
// 轨迹详情面板的「记忆审计」页签。Trajectory 没有行级/页签级 slot,所以
|
|
456
|
+
// 按钮和面板都放在 shell.overlay 里用 fixed 定位贴着详情面板;不在 React
|
|
457
|
+
// 管理的 tabs 行里插 DOM,避免被轨迹的重渲染清掉。
|
|
458
|
+
'.mem-traj-audit-tab{position:fixed;z-index:71;box-sizing:border-box;display:flex;align-items:center;justify-content:center;height:26px;padding:0 8px;border:0;border-bottom:2px solid transparent;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-tertiary);font-size:13px;font-weight:500;line-height:16px;white-space:nowrap;cursor:pointer;pointer-events:auto}',
|
|
459
|
+
'.mem-traj-audit-tab:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}',
|
|
460
|
+
'.mem-traj-audit-tab.on{color:var(--dsw-alias-state-business-primary);border-bottom-color:var(--dsw-alias-state-business-primary)}',
|
|
461
|
+
'.mem-traj-audit-pane{position:fixed;z-index:72;box-sizing:border-box;display:flex;flex-direction:column;overflow:hidden;border-left:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);pointer-events:auto}',
|
|
462
|
+
'.mem-traj-audit-pane-head{display:flex;align-items:center;gap:8px;flex:none;padding:8px 10px;border-bottom:.5px solid var(--dsw-alias-border-l1)}',
|
|
463
|
+
'.mem-traj-audit-pane-head b{font-size:12px}',
|
|
464
|
+
'.mem-traj-audit-pane-head .spacer{flex:1}',
|
|
465
|
+
'.mem-traj-audit-pane-body{flex:1;min-height:0;overflow:auto;padding:6px 10px 10px;display:flex;flex-direction:column;gap:6px}',
|
|
466
|
+
'.mem-traj-audit-pane-foot{flex:none;display:flex;gap:6px;align-items:center;padding:8px 10px;border-top:.5px solid var(--dsw-alias-border-l1)}',
|
|
467
|
+
'.mem-traj-audit-pane-foot .spacer{flex:1}',
|
|
468
|
+
'.mem-traj-audit-row{display:flex;flex-direction:column;gap:4px;text-align:left;width:100%;box-sizing:border-box;padding:7px 8px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);cursor:pointer;color:inherit;font-size:11.5px}',
|
|
469
|
+
'.mem-traj-audit-row:hover{border-color:var(--dsw-alias-brand-primary)}',
|
|
470
|
+
'.mem-traj-audit-row-top{display:flex;align-items:center;gap:6px;min-width:0}',
|
|
471
|
+
'.mem-traj-audit-row-top .t{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:10px;color:var(--dsw-alias-label-secondary);flex:none}',
|
|
472
|
+
'.mem-traj-audit-row-top .ch{font-weight:600;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
473
|
+
'.mem-traj-audit-row-meta{font-size:10.5px;color:var(--dsw-alias-label-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
474
|
+
'.mem-traj-audit-row-ids{display:flex;flex-wrap:wrap;gap:3px;max-height:44px;overflow:hidden}',
|
|
475
|
+
'.mem-traj-audit-empty{padding:16px 8px;color:var(--dsw-alias-label-secondary);font-size:11.5px;line-height:1.6}',
|
|
476
|
+
// 轨迹行上的记忆徽标:fixed 定位在选中行右侧,不改轨迹表格结构。
|
|
477
|
+
'.mem-traj-chip{position:fixed;z-index:70;display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 7px;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary) 42%,var(--dsw-alias-border-l1));border-radius:999px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-brand-primary);font-size:10px;line-height:1;cursor:pointer;box-shadow:0 2px 8px rgba(0,0,0,.18);white-space:nowrap}',
|
|
478
|
+
'.mem-traj-chip:hover{background:color-mix(in srgb,var(--dsw-alias-brand-primary) 10%,var(--dsw-alias-bg-layer-1))}',
|
|
479
|
+
'.mem-traj-chip .dot{width:5px;height:5px;border-radius:50%;background:currentColor}',
|
|
437
480
|
'@media (max-width:900px){.memp .audit-split.has-detail{grid-template-columns:minmax(0,1fr)}.memp .audit-row{grid-template-columns:54px 120px 120px minmax(100px,1fr) 96px 100px 80px}.memp .audit-table-head{grid-template-columns:54px 120px 120px minmax(100px,1fr) 96px 100px 80px}}',
|
|
438
481
|
'@media (max-width:620px){.memp .audit-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.memp .audit-table-head{display:none}.memp .audit-row{display:flex;flex-wrap:wrap;gap:4px 8px}.memp .audit-row .col-trigger,.memp .audit-row .col-budget{display:none}.memp .audit-row .col-nums{margin-left:auto}.memp .audit-row .col-time{order:1}.memp .audit-row .col-channel{order:2}.memp .audit-row .col-delivery{order:3}.memp .audit-row .col-outcome{order:4;margin-left:auto}.memp .audit-filter-row input[type=text],.memp .audit-filter-row input[type=search]{max-width:none;flex:1}.memp .audit{height:calc(100vh - 150px);max-height:calc(100vh - 150px)}.memp .audit-detail{max-height:calc(100vh - 280px)}}',
|
|
439
482
|
].join('')
|
|
@@ -2060,6 +2103,219 @@ window.__ModuleLoader__.load({
|
|
|
2060
2103
|
)
|
|
2061
2104
|
}
|
|
2062
2105
|
|
|
2106
|
+
// ===== 记忆审计 ↔ 会话轨迹 的桥接 =====
|
|
2107
|
+
//
|
|
2108
|
+
// DSH 的 Trajectory 面板是一个纯投影:它只声明 `conversation.trajectory.images`
|
|
2109
|
+
// 一个子槽,没有行/列的扩展点,选中状态也是组件私有的。但它**支持按 callId
|
|
2110
|
+
// 深链聚焦**(`toolCallFocus` 就是同一性映射),而每个 `conversation.view`
|
|
2111
|
+
// 的渲染产物都会收到 `openView(view, focus)`。所以:
|
|
2112
|
+
// - 会话内的「记忆审计」视图直接用 openView('trajectory', callId);
|
|
2113
|
+
// - 主面板(不在会话视图树里)通过 `conversation.session` 条目挂的 per-session
|
|
2114
|
+
// store 调同一个 action。这里是宿主 slot 服务的内部字段(`_stores`),
|
|
2115
|
+
// 全部做了存在性判断;拿不到就退化成“只打开会话/只切轨迹页”,绝不 throw。
|
|
2116
|
+
let clientCtx = null
|
|
2117
|
+
const AUDIT_FOCUS_EVENT = 'dsh-memory:audit-focus'
|
|
2118
|
+
let pendingAuditFocus = null
|
|
2119
|
+
|
|
2120
|
+
function safeSlots() {
|
|
2121
|
+
try { return clientCtx?.get?.('slots') } catch { return undefined }
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
function uiWorkspace() {
|
|
2125
|
+
try { return clientCtx?.get?.('uiWorkspace') } catch { return undefined }
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
function openSessionById(id) {
|
|
2129
|
+
if (typeof id !== 'string' || id === '') return
|
|
2130
|
+
try {
|
|
2131
|
+
const workspace = uiWorkspace()
|
|
2132
|
+
if (workspace && typeof workspace.openSession === 'function') {
|
|
2133
|
+
workspace.openSession(id)
|
|
2134
|
+
return
|
|
2135
|
+
}
|
|
2136
|
+
if (typeof window !== 'undefined') window.location.hash = `#/s/${encodeURIComponent(id)}`
|
|
2137
|
+
} catch { /* 旧宿主没有 uiWorkspace:保持原状 */ }
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
/** 当前主视图保留的会话(Host 用 retainedBy.mainView 标出)。 */
|
|
2141
|
+
function currentSessionId() {
|
|
2142
|
+
try {
|
|
2143
|
+
const snapshot = uiWorkspace()?.sessions?.list?.getSnapshot?.()
|
|
2144
|
+
const rows = snapshot && snapshot.byId ? Object.values(snapshot.byId) : []
|
|
2145
|
+
const current = rows.find((row) => row && row.retainedBy && (row.retainedBy.mainView ?? 0) > 0)
|
|
2146
|
+
return current && typeof current.id === 'string' ? current.id : undefined
|
|
2147
|
+
} catch {
|
|
2148
|
+
return undefined
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
/** 审计条目的轨迹锚:优先 operationId(记忆工具调用/工具信号),其次 signal.callId。 */
|
|
2153
|
+
function auditEntryCallId(entry) {
|
|
2154
|
+
if (!entry || typeof entry !== 'object') return undefined
|
|
2155
|
+
if (typeof entry.operationId === 'string' && entry.operationId !== '') return entry.operationId
|
|
2156
|
+
const signalCall = entry.signal && typeof entry.signal.callId === 'string' ? entry.signal.callId : ''
|
|
2157
|
+
return signalCall !== '' ? signalCall : undefined
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
/** Trajectory 的行 key 形如 `tool\0call\0<callId>`;解析失败返回 undefined。 */
|
|
2161
|
+
function trajectoryRowCallId(row) {
|
|
2162
|
+
try {
|
|
2163
|
+
const key = row && typeof row.getAttribute === 'function' ? row.getAttribute('data-trajectory-row-key') : ''
|
|
2164
|
+
if (typeof key !== 'string') return undefined
|
|
2165
|
+
const sep = '\u0000call\u0000'
|
|
2166
|
+
const at = key.indexOf(sep)
|
|
2167
|
+
return at >= 0 ? key.slice(at + sep.length) : undefined
|
|
2168
|
+
} catch {
|
|
2169
|
+
return undefined
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
/**
|
|
2174
|
+
* `conversation.session` 注册时把 per-session store 交给 slot 服务;服务把实例
|
|
2175
|
+
* 放在 `_stores` 的 handle 记录里,按 session id 解析。这是主面板唯一能拿到
|
|
2176
|
+
* `openView` 的路径(slot 只把 actions 交给注册者自己)。
|
|
2177
|
+
*/
|
|
2178
|
+
function conversationStoreFor(sessionId) {
|
|
2179
|
+
if (typeof sessionId !== 'string' || sessionId === '') return undefined
|
|
2180
|
+
try {
|
|
2181
|
+
const slots = safeSlots()
|
|
2182
|
+
const entries = slots?.entries?.('conversation.session') ?? []
|
|
2183
|
+
const handle = entries.map((entry) => entry?.store).find((value) => value !== undefined)
|
|
2184
|
+
if (handle === undefined) return undefined
|
|
2185
|
+
const record = slots?._stores?.get?.(handle)
|
|
2186
|
+
const instances = record && record.instances
|
|
2187
|
+
if (!(instances instanceof Map)) return undefined
|
|
2188
|
+
const direct = instances.get(sessionId)
|
|
2189
|
+
if (direct !== undefined) return direct
|
|
2190
|
+
for (const [key, store] of instances) {
|
|
2191
|
+
if (String(key) === sessionId || String(key).endsWith(sessionId)) return store
|
|
2192
|
+
}
|
|
2193
|
+
if (instances.size === 1) return [...instances.values()][0]
|
|
2194
|
+
return undefined
|
|
2195
|
+
} catch {
|
|
2196
|
+
return undefined
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
function setConversationView(sessionId, view, focus) {
|
|
2201
|
+
const store = conversationStoreFor(sessionId)
|
|
2202
|
+
const actions = store && store.actions
|
|
2203
|
+
if (!actions) return false
|
|
2204
|
+
try {
|
|
2205
|
+
if (typeof actions.openView === 'function') {
|
|
2206
|
+
actions.openView(view, focus)
|
|
2207
|
+
return true
|
|
2208
|
+
}
|
|
2209
|
+
if (typeof actions.setView === 'function') {
|
|
2210
|
+
actions.setView(view)
|
|
2211
|
+
return true
|
|
2212
|
+
}
|
|
2213
|
+
} catch { /* action 失败:调用方退化成打开会话 */ }
|
|
2214
|
+
return false
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
/** 打开会话并把 Trajectory 切到指定 callId;拿不到 store 时轮询等待会话挂载。 */
|
|
2218
|
+
async function jumpToTrajectory(sessionId, focus) {
|
|
2219
|
+
if (typeof sessionId !== 'string' || sessionId === '') return { opened: false, focused: false }
|
|
2220
|
+
openSessionById(sessionId)
|
|
2221
|
+
for (let attempt = 0; attempt < 40; attempt += 1) {
|
|
2222
|
+
const store = conversationStoreFor(sessionId)
|
|
2223
|
+
const actions = store && store.actions
|
|
2224
|
+
if (actions) {
|
|
2225
|
+
try {
|
|
2226
|
+
if (focus !== undefined && typeof actions.openView === 'function') {
|
|
2227
|
+
actions.openView('trajectory', focus)
|
|
2228
|
+
return { opened: true, focused: true }
|
|
2229
|
+
}
|
|
2230
|
+
if (typeof actions.setView === 'function') {
|
|
2231
|
+
actions.setView('trajectory')
|
|
2232
|
+
return { opened: true, focused: false }
|
|
2233
|
+
}
|
|
2234
|
+
} catch { /* 继续重试 */ }
|
|
2235
|
+
}
|
|
2236
|
+
await new Promise((resolve) => setTimeout(resolve, 75))
|
|
2237
|
+
}
|
|
2238
|
+
return { opened: false, focused: false }
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
/** 无 operationId 时,用 turn/step 去 Host 的会话事件里找该步的工具调用。 */
|
|
2242
|
+
async function resolveAuditFocus(entry) {
|
|
2243
|
+
const direct = auditEntryCallId(entry)
|
|
2244
|
+
if (direct !== undefined) return direct
|
|
2245
|
+
if (!entry || typeof entry.sessionId !== 'string' || entry.sessionId === '') return undefined
|
|
2246
|
+
if (typeof entry.turn !== 'number' && typeof entry.step !== 'number') return undefined
|
|
2247
|
+
try {
|
|
2248
|
+
const params = new URLSearchParams({ session: entry.sessionId })
|
|
2249
|
+
if (typeof entry.turn === 'number') params.set('turn', String(entry.turn))
|
|
2250
|
+
if (typeof entry.step === 'number') params.set('step', String(entry.step))
|
|
2251
|
+
const value = await api(`anchor?${params.toString()}`)
|
|
2252
|
+
return value && typeof value.callId === 'string' && value.callId !== '' ? value.callId : undefined
|
|
2253
|
+
} catch {
|
|
2254
|
+
return undefined
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
async function jumpAuditEntryToTrajectory(entry) {
|
|
2259
|
+
if (!entry || typeof entry.sessionId !== 'string' || entry.sessionId === '') {
|
|
2260
|
+
return { opened: false, focused: false, reason: 'no_session' }
|
|
2261
|
+
}
|
|
2262
|
+
const focus = await resolveAuditFocus(entry)
|
|
2263
|
+
const result = await jumpToTrajectory(entry.sessionId, focus)
|
|
2264
|
+
return { ...result, reason: focus === undefined ? 'no_anchor' : 'focused' }
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
function requestAuditFocus(target) {
|
|
2268
|
+
pendingAuditFocus = target && typeof target === 'object' ? { ...target, at: Date.now() } : null
|
|
2269
|
+
try {
|
|
2270
|
+
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof CustomEvent === 'function') {
|
|
2271
|
+
window.dispatchEvent(new CustomEvent(AUDIT_FOCUS_EVENT, { detail: pendingAuditFocus }))
|
|
2272
|
+
}
|
|
2273
|
+
} catch { /* 没有 CustomEvent 时靠挂载时取一次 */ }
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
function takeAuditFocus(audience) {
|
|
2277
|
+
const target = pendingAuditFocus
|
|
2278
|
+
if (!target) return null
|
|
2279
|
+
if (audience && target.audience && target.audience !== audience) return null
|
|
2280
|
+
pendingAuditFocus = null
|
|
2281
|
+
return target
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
/** 只读探测:面板挂载时据此先切到「审计」标签,再让 AuditTab 自己消费。 */
|
|
2285
|
+
function peekAuditFocus(audience) {
|
|
2286
|
+
const target = pendingAuditFocus
|
|
2287
|
+
if (!target) return null
|
|
2288
|
+
if (audience && target.audience && target.audience !== audience) return null
|
|
2289
|
+
return target
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
/**
|
|
2293
|
+
* 从轨迹/头部入口打开记忆审计:优先主面板;没有侧栏入口时切到会话内的
|
|
2294
|
+
* 「记忆」视图;两者都不可用时至少打开设置页(面板挂载后会消费 pending)。
|
|
2295
|
+
*/
|
|
2296
|
+
function openMemoryAuditPanel(target) {
|
|
2297
|
+
const sessionId = target && typeof target.sessionId === 'string' ? target.sessionId : undefined
|
|
2298
|
+
try {
|
|
2299
|
+
const main = safeSlots()?.entries?.('main') ?? []
|
|
2300
|
+
if (main.some((entry) => entry?.options?.key === 'memory')) {
|
|
2301
|
+
requestAuditFocus({ ...target, audience: 'panel' })
|
|
2302
|
+
try { clientCtx?.get?.('layout')?.selectPanel?.('memory') } catch { /* 交给挂载消费 */ }
|
|
2303
|
+
return 'panel'
|
|
2304
|
+
}
|
|
2305
|
+
} catch { /* fallthrough */ }
|
|
2306
|
+
try {
|
|
2307
|
+
const views = safeSlots()?.entries?.('conversation.view') ?? []
|
|
2308
|
+
const hasView = views.some((entry) => entry?.options?.id === 'memory')
|
|
2309
|
+
if (hasView && sessionId !== undefined && conversationStoreFor(sessionId) !== undefined) {
|
|
2310
|
+
requestAuditFocus({ ...target, audience: 'view' })
|
|
2311
|
+
if (setConversationView(sessionId, 'memory')) return 'view'
|
|
2312
|
+
}
|
|
2313
|
+
} catch { /* fallthrough */ }
|
|
2314
|
+
requestAuditFocus({ ...target, audience: 'panel' })
|
|
2315
|
+
try { clientCtx?.get?.('layout')?.selectPanel?.('settings') } catch { /* 无布局服务 */ }
|
|
2316
|
+
return 'settings'
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2063
2319
|
// ===== 审计标签页 =====
|
|
2064
2320
|
const AUDIT_CHANNEL_META = {
|
|
2065
2321
|
digest: '摘要', recall: '召回', rules: '规则', rules_delta: '规则增量',
|
|
@@ -2121,6 +2377,7 @@ window.__ModuleLoader__.load({
|
|
|
2121
2377
|
return `${meta.label}${meta.detail}${entry.delivery && entry.delivery.textChars ? ` · ${entry.delivery.textChars} 字符` : ''}`
|
|
2122
2378
|
}
|
|
2123
2379
|
if (entry.kind === 'signal') {
|
|
2380
|
+
if (entry.stage === 'tool_call') return `记忆工具调用${entry.signal && entry.signal.tool ? ` · ${entry.signal.tool}` : ''}`
|
|
2124
2381
|
const stage = entry.stage === 'signal_consumed' ? '信号已消费' : entry.stage === 'signal_dropped' ? '信号被丢弃' : '信号已排队'
|
|
2125
2382
|
return `${stage}${entry.signal && entry.signal.reason ? ` · ${entry.signal.reason}` : ''}`
|
|
2126
2383
|
}
|
|
@@ -2165,7 +2422,16 @@ window.__ModuleLoader__.load({
|
|
|
2165
2422
|
tag_mismatch: '标签不匹配', dedup: '去重', excluded: '被排除', skipped: '跳过',
|
|
2166
2423
|
}
|
|
2167
2424
|
|
|
2168
|
-
function AuditTab({
|
|
2425
|
+
function AuditTab({
|
|
2426
|
+
scopes,
|
|
2427
|
+
records = [],
|
|
2428
|
+
openRecord,
|
|
2429
|
+
openSession,
|
|
2430
|
+
sessionInfo,
|
|
2431
|
+
audience = 'panel',
|
|
2432
|
+
lockSession,
|
|
2433
|
+
openTrajectory,
|
|
2434
|
+
}) {
|
|
2169
2435
|
const [entries, setEntries] = React.useState([])
|
|
2170
2436
|
const [stats, setStats] = React.useState(null)
|
|
2171
2437
|
const [total, setTotal] = React.useState(0)
|
|
@@ -2176,10 +2442,12 @@ window.__ModuleLoader__.load({
|
|
|
2176
2442
|
const [error, setError] = React.useState('')
|
|
2177
2443
|
const [copyNotice, setCopyNotice] = React.useState('')
|
|
2178
2444
|
const [exportNotice, setExportNotice] = React.useState('')
|
|
2445
|
+
const [focusNotice, setFocusNotice] = React.useState('')
|
|
2446
|
+
const [focusBusy, setFocusBusy] = React.useState(false)
|
|
2179
2447
|
const [autoRefresh, setAutoRefresh] = React.useState(true)
|
|
2180
2448
|
const [refreshMs, setRefreshMs] = React.useState(500)
|
|
2181
2449
|
const loadingRef = React.useRef(false)
|
|
2182
|
-
const [session, setSession] = React.useState(readAuditSession())
|
|
2450
|
+
const [session, setSession] = React.useState(lockSession || readAuditSession())
|
|
2183
2451
|
const [channel, setChannel] = React.useState('')
|
|
2184
2452
|
const [outcome, setOutcome] = React.useState('')
|
|
2185
2453
|
const [trigger, setTrigger] = React.useState('')
|
|
@@ -2194,10 +2462,11 @@ window.__ModuleLoader__.load({
|
|
|
2194
2462
|
const [recordCache, setRecordCache] = React.useState({})
|
|
2195
2463
|
const tipTimer = React.useRef(null)
|
|
2196
2464
|
const hideTimer = React.useRef(null)
|
|
2465
|
+
const effectiveSession = lockSession || session
|
|
2197
2466
|
|
|
2198
2467
|
function queryParams(cursorValue) {
|
|
2199
2468
|
const params = new URLSearchParams()
|
|
2200
|
-
if (
|
|
2469
|
+
if (effectiveSession) params.set('session', effectiveSession)
|
|
2201
2470
|
if (channel) params.set('channel', channel)
|
|
2202
2471
|
if (outcome) params.set('outcome', outcome)
|
|
2203
2472
|
if (trigger.trim()) params.set('trigger', trigger.trim())
|
|
@@ -2245,6 +2514,38 @@ window.__ModuleLoader__.load({
|
|
|
2245
2514
|
|
|
2246
2515
|
React.useEffect(() => { load('', []) }, [reloadTick])
|
|
2247
2516
|
|
|
2517
|
+
// 从轨迹行/会话头部跳到审计时,可能带着 session + callId + 具体事件 id。
|
|
2518
|
+
// 面板挂载时先取一次 pending,之后靠同一个 window 事件接收(面板已经在
|
|
2519
|
+
// 屏幕上时不必重挂)。只消费与自己 audience 匹配的目标。
|
|
2520
|
+
React.useEffect(() => {
|
|
2521
|
+
const applyFocus = () => {
|
|
2522
|
+
const target = takeAuditFocus(audience)
|
|
2523
|
+
if (!target) return
|
|
2524
|
+
if (!lockSession && typeof target.sessionId === 'string' && target.sessionId !== '') {
|
|
2525
|
+
setSession(target.sessionId)
|
|
2526
|
+
writeAuditSession(target.sessionId)
|
|
2527
|
+
}
|
|
2528
|
+
if (typeof target.callId === 'string' && target.callId !== '') {
|
|
2529
|
+
setSearch(`op:${target.callId}`)
|
|
2530
|
+
setFocusNotice(`已定位到轨迹调用 ${target.callId.slice(0, 12)}`)
|
|
2531
|
+
} else if (!lockSession) {
|
|
2532
|
+
setSearch('')
|
|
2533
|
+
}
|
|
2534
|
+
if (typeof target.entryId === 'string' && target.entryId !== '') setSelectedId(target.entryId)
|
|
2535
|
+
setReloadTick((n) => n + 1)
|
|
2536
|
+
}
|
|
2537
|
+
applyFocus()
|
|
2538
|
+
const onFocus = () => applyFocus()
|
|
2539
|
+
try {
|
|
2540
|
+
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') window.addEventListener(AUDIT_FOCUS_EVENT, onFocus)
|
|
2541
|
+
} catch { /* 没有 window 事件也能靠挂载时消费 */ }
|
|
2542
|
+
return () => {
|
|
2543
|
+
try {
|
|
2544
|
+
if (typeof window !== 'undefined' && typeof window.removeEventListener === 'function') window.removeEventListener(AUDIT_FOCUS_EVENT, onFocus)
|
|
2545
|
+
} catch { /* cleanup 失败不影响面板 */ }
|
|
2546
|
+
}
|
|
2547
|
+
}, [audience, lockSession])
|
|
2548
|
+
|
|
2248
2549
|
// 自动刷新:默认 500ms,可关;页面隐藏时跳过,避免后台无意义轮询。
|
|
2249
2550
|
React.useEffect(() => {
|
|
2250
2551
|
if (!autoRefresh) return undefined
|
|
@@ -2253,7 +2554,7 @@ window.__ModuleLoader__.load({
|
|
|
2253
2554
|
load(cursor, cursorStack, { silent: true })
|
|
2254
2555
|
}, refreshMs)
|
|
2255
2556
|
return () => clearInterval(timer)
|
|
2256
|
-
}, [autoRefresh, refreshMs, cursor, cursorStack,
|
|
2557
|
+
}, [autoRefresh, refreshMs, cursor, cursorStack, effectiveSession, channel, outcome, trigger, search, problem, range, since, until])
|
|
2257
2558
|
|
|
2258
2559
|
const resetAndReload = () => { setCursor(''); setCursorStack([]); setReloadTick((n) => n + 1) }
|
|
2259
2560
|
const selected = selectedId === null ? null : entries.find((entry) => entry.id === selectedId) || null
|
|
@@ -2358,8 +2659,8 @@ window.__ModuleLoader__.load({
|
|
|
2358
2659
|
value: scope.scope.slice(8),
|
|
2359
2660
|
label: scope.label || `会话 ${scope.scope.slice(8, 16)}`,
|
|
2360
2661
|
})))
|
|
2361
|
-
if (
|
|
2362
|
-
sessionOptions.push({ value:
|
|
2662
|
+
if (effectiveSession && !sessionOptions.some((item) => item.value === effectiveSession)) {
|
|
2663
|
+
sessionOptions.push({ value: effectiveSession, label: `会话 ${effectiveSession.slice(0, 8)}` })
|
|
2363
2664
|
}
|
|
2364
2665
|
const channelOptions = [{ value: '', label: '全部通道' }].concat(Object.keys(AUDIT_CHANNEL_META).map((key) => ({ value: key, label: AUDIT_CHANNEL_META[key] })))
|
|
2365
2666
|
const outcomeOptions = [{ value: '', label: '全部结果' }].concat(Object.keys(AUDIT_OUTCOME_META).map((key) => ({ value: key, label: AUDIT_OUTCOME_META[key].label })))
|
|
@@ -2396,13 +2697,15 @@ window.__ModuleLoader__.load({
|
|
|
2396
2697
|
banner.push(h('div', { className: 'audit-banner bad', key: 'err' }, `审计写入失败 ${writeErrors} 次;面板数据可能不完整。`))
|
|
2397
2698
|
}
|
|
2398
2699
|
|
|
2399
|
-
const filterActive = Boolean(
|
|
2700
|
+
const filterActive = Boolean(effectiveSession || channel || outcome || trigger || search || problem || range)
|
|
2400
2701
|
const toolbar = h('div', { className: 'audit-toolbar' },
|
|
2401
2702
|
h('div', { className: 'audit-filter-row' },
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2703
|
+
lockSession
|
|
2704
|
+
? h('span', { className: 'audit-pill mute', title: lockSession }, `会话 ${String(lockSession).slice(0, 10)}`)
|
|
2705
|
+
: h(Dropdown, {
|
|
2706
|
+
items: sessionOptions, value: session, disabled: loading,
|
|
2707
|
+
onChange: (next) => { setSession(next); writeAuditSession(next); resetAndReload() },
|
|
2708
|
+
}),
|
|
2406
2709
|
h(Dropdown, {
|
|
2407
2710
|
items: channelOptions, value: channel, disabled: loading,
|
|
2408
2711
|
onChange: (next) => { setChannel(next); resetAndReload() },
|
|
@@ -2462,7 +2765,7 @@ window.__ModuleLoader__.load({
|
|
|
2462
2765
|
: null,
|
|
2463
2766
|
filterActive
|
|
2464
2767
|
? h('button', { className: 'linkbtn', onClick: () => {
|
|
2465
|
-
setSession(''); writeAuditSession(''); setChannel(''); setOutcome(''); setTrigger(''); setSearch(''); setProblem(false); setRange(''); setSince(''); setUntil(''); resetAndReload()
|
|
2768
|
+
setSession(lockSession || ''); if (!lockSession) writeAuditSession(''); setChannel(''); setOutcome(''); setTrigger(''); setSearch(''); setProblem(false); setRange(''); setSince(''); setUntil(''); resetAndReload()
|
|
2466
2769
|
} }, '清空筛选')
|
|
2467
2770
|
: null,
|
|
2468
2771
|
h('span', { className: 'spacer' }),
|
|
@@ -2544,15 +2847,48 @@ window.__ModuleLoader__.load({
|
|
|
2544
2847
|
onClick: () => openSessionId(selected.sessionId),
|
|
2545
2848
|
}, selected.sessionId))]
|
|
2546
2849
|
: null
|
|
2850
|
+
const directCall = auditEntryCallId(selected)
|
|
2851
|
+
const hasStep = typeof selected.turn === 'number' || typeof selected.step === 'number'
|
|
2852
|
+
const jumpTarget = directCall !== undefined
|
|
2853
|
+
? `callId ${directCall}`
|
|
2854
|
+
: hasStep ? `第 ${selected.turn ?? '?'} 轮 / 第 ${selected.step ?? '?'} 步(按步查找)` : undefined
|
|
2855
|
+
const onJump = async () => {
|
|
2856
|
+
if (!selected.sessionId) return
|
|
2857
|
+
setFocusBusy(true)
|
|
2858
|
+
setFocusNotice('')
|
|
2859
|
+
try {
|
|
2860
|
+
const focus = await resolveAuditFocus(selected)
|
|
2861
|
+
if (typeof openTrajectory === 'function') {
|
|
2862
|
+
openTrajectory(focus)
|
|
2863
|
+
setFocusNotice(focus === undefined ? '已切到轨迹页(这条没有精确锚点)' : '已定位到轨迹')
|
|
2864
|
+
return
|
|
2865
|
+
}
|
|
2866
|
+
const result = await jumpAuditEntryToTrajectory(selected)
|
|
2867
|
+
setFocusNotice(result.focused ? '已定位到轨迹' : result.opened ? '已切到轨迹页(未找到精确锚点)' : '打开轨迹失败')
|
|
2868
|
+
} catch {
|
|
2869
|
+
setFocusNotice('定位失败')
|
|
2870
|
+
} finally {
|
|
2871
|
+
setFocusBusy(false)
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2547
2874
|
const json = JSON.stringify(selected, null, 2)
|
|
2548
2875
|
return h('div', { className: 'audit-detail' },
|
|
2549
2876
|
h('div', { className: 'audit-detail-head' },
|
|
2550
2877
|
h('b', null, auditSummaryLine(selected)),
|
|
2551
2878
|
h('span', { className: 'spacer' }),
|
|
2879
|
+
selected.sessionId
|
|
2880
|
+
? h('button', {
|
|
2881
|
+
className: 'audit-jump',
|
|
2882
|
+
disabled: focusBusy,
|
|
2883
|
+
title: jumpTarget === undefined ? '切到该会话的轨迹页(本条没有 callId/turn/step 锚点)' : `在轨迹中定位:${jumpTarget}`,
|
|
2884
|
+
onClick: onJump,
|
|
2885
|
+
}, focusBusy ? '定位中…' : '在轨迹中定位')
|
|
2886
|
+
: null,
|
|
2552
2887
|
h('button', { className: 'linkbtn', onClick: () => copyAuditText(selected.id, setCopyNotice) }, '复制 ID'),
|
|
2553
2888
|
copyNotice ? h('span', { className: 'audit-inline-note' }, copyNotice) : null,
|
|
2554
2889
|
h('button', { className: 'audit-close', title: '关闭', onClick: () => { setSelectedId(null); setCopyNotice('') } }, '×'),
|
|
2555
2890
|
),
|
|
2891
|
+
focusNotice ? h('div', { className: 'audit-jump-note' }, focusNotice) : null,
|
|
2556
2892
|
h('div', { className: 'audit-kv' },
|
|
2557
2893
|
kv('事件', selected.id),
|
|
2558
2894
|
kv('序号', selected.seq),
|
|
@@ -2560,6 +2896,7 @@ window.__ModuleLoader__.load({
|
|
|
2560
2896
|
kv('schema', selected.schemaVersion || '旧版'),
|
|
2561
2897
|
sessionNode,
|
|
2562
2898
|
kv('step', selected.step),
|
|
2899
|
+
kv('轨迹锚点', jumpTarget),
|
|
2563
2900
|
kv('通道', `${auditChannelLabel(selected.channel)} / ${selected.kind}`),
|
|
2564
2901
|
kv('阶段', selected.stage),
|
|
2565
2902
|
kv('触发', selected.trigger),
|
|
@@ -2745,7 +3082,7 @@ window.__ModuleLoader__.load({
|
|
|
2745
3082
|
/** 待嵌入自动刷新:最多 300 次 × 1.5s(后端挂着时不无限轮询)。 */
|
|
2746
3083
|
const PENDING_POLL_LIMIT = 300
|
|
2747
3084
|
|
|
2748
|
-
function MemoryPanel({ openSession, sessionInfo } = {}) {
|
|
3085
|
+
function MemoryPanel({ openSession, sessionInfo, openTrajectory, audience = 'panel', lockSession } = {}) {
|
|
2749
3086
|
const [records, setRecords] = React.useState([])
|
|
2750
3087
|
const [scopes, setScopes] = React.useState([])
|
|
2751
3088
|
const [embedServer, setEmbedServer] = React.useState(null)
|
|
@@ -2766,6 +3103,21 @@ window.__ModuleLoader__.load({
|
|
|
2766
3103
|
const [pendingTick, setPendingTick] = React.useState(0)
|
|
2767
3104
|
const [creating, setCreating] = React.useState(false)
|
|
2768
3105
|
|
|
3106
|
+
// 从轨迹/会话头部带进来的焦点:面板可能正停在「记录」页,先切到「审计」,
|
|
3107
|
+
// 具体的 session/entry 过滤由 AuditTab 挂载时消费。
|
|
3108
|
+
React.useEffect(() => {
|
|
3109
|
+
const sync = () => { if (peekAuditFocus(audience) !== null) setTab('audit') }
|
|
3110
|
+
sync()
|
|
3111
|
+
try {
|
|
3112
|
+
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') window.addEventListener(AUDIT_FOCUS_EVENT, sync)
|
|
3113
|
+
} catch { /* 无事件环境 */ }
|
|
3114
|
+
return () => {
|
|
3115
|
+
try {
|
|
3116
|
+
if (typeof window !== 'undefined' && typeof window.removeEventListener === 'function') window.removeEventListener(AUDIT_FOCUS_EVENT, sync)
|
|
3117
|
+
} catch { /* cleanup 失败不影响面板 */ }
|
|
3118
|
+
}
|
|
3119
|
+
}, [audience])
|
|
3120
|
+
|
|
2769
3121
|
const load = async (query, scopeF, semanticF) => {
|
|
2770
3122
|
setLoading(true); setError('')
|
|
2771
3123
|
try {
|
|
@@ -3210,18 +3562,417 @@ window.__ModuleLoader__.load({
|
|
|
3210
3562
|
: tab === 'tree'
|
|
3211
3563
|
? treeBody
|
|
3212
3564
|
: tab === 'audit'
|
|
3213
|
-
? h(AuditTab, {
|
|
3565
|
+
? h(AuditTab, {
|
|
3566
|
+
scopes,
|
|
3567
|
+
records,
|
|
3568
|
+
openRecord,
|
|
3569
|
+
openSession,
|
|
3570
|
+
sessionInfo,
|
|
3571
|
+
audience,
|
|
3572
|
+
lockSession,
|
|
3573
|
+
openTrajectory,
|
|
3574
|
+
})
|
|
3214
3575
|
: overviewBody,
|
|
3215
3576
|
)
|
|
3216
3577
|
}
|
|
3217
3578
|
|
|
3579
|
+
/**
|
|
3580
|
+
* 会话内的「记忆审计」视图:和 Chat/Trajectory 同一个 view ring。
|
|
3581
|
+
*
|
|
3582
|
+
* 它拿到 owner 传下来的 `openView(view, focus)`,所以从这里跳轨迹是宿主
|
|
3583
|
+
* 官方支持的深链路径,不依赖任何内部字段。主面板(侧栏/设置)不在 view
|
|
3584
|
+
* ring 里,走 `conversationStoreFor` 的 bridge。
|
|
3585
|
+
*/
|
|
3586
|
+
function MemoryAuditView({ sessionId, openView, sessionInfo }) {
|
|
3587
|
+
const openTrajectory = (focus) => {
|
|
3588
|
+
try {
|
|
3589
|
+
if (typeof openView === 'function') openView('trajectory', focus)
|
|
3590
|
+
} catch { /* 视图不可用时保持在本页 */ }
|
|
3591
|
+
}
|
|
3592
|
+
return h('div', {
|
|
3593
|
+
className: 'memp mem-view',
|
|
3594
|
+
// 让宿主把 composer 浮起来、把 viewArea 压成固定高度(与 Trajectory 同一机制),
|
|
3595
|
+
// 否则外层 scrollBody 会滚动,审计列表拿不到自己的滚动视口。
|
|
3596
|
+
'data-conversation-composer-overlay': '',
|
|
3597
|
+
},
|
|
3598
|
+
h('div', { className: 'mem-view-head' },
|
|
3599
|
+
h('b', null, '记忆审计'),
|
|
3600
|
+
h('span', { className: 'muted' }, '本会话的注入评估、投递与记忆工具调用;选中一条可在轨迹里精确定位。'),
|
|
3601
|
+
h('span', { className: 'spacer' }),
|
|
3602
|
+
h('button', {
|
|
3603
|
+
className: 'linkbtn',
|
|
3604
|
+
onClick: () => openMemoryAuditPanel({ sessionId }),
|
|
3605
|
+
}, '打开完整面板'),
|
|
3606
|
+
),
|
|
3607
|
+
h('div', { className: 'mem-view-body' },
|
|
3608
|
+
h(AuditTab, {
|
|
3609
|
+
scopes: [],
|
|
3610
|
+
records: [],
|
|
3611
|
+
sessionInfo,
|
|
3612
|
+
lockSession: sessionId,
|
|
3613
|
+
audience: 'view',
|
|
3614
|
+
openTrajectory,
|
|
3615
|
+
}),
|
|
3616
|
+
),
|
|
3617
|
+
)
|
|
3618
|
+
}
|
|
3619
|
+
|
|
3620
|
+
/**
|
|
3621
|
+
* Trajectory 行上的记忆徽标。
|
|
3622
|
+
*
|
|
3623
|
+
* Trajectory 不提供行级 slot,选中状态也只存在于组件内部。这里用宿主已经
|
|
3624
|
+
* 渲染到 DOM 上的稳定属性(`data-selected` / `data-trajectory-row-key`:
|
|
3625
|
+
* `kind\0call\0<callId>`)做只读观察,再把一个 fixed 徽标浮在选中行右侧。
|
|
3626
|
+
* 它不插入表格、不改轨迹结构;选择器失配时什么都不显示。
|
|
3627
|
+
*/
|
|
3628
|
+
function TrajectoryMemoryBadge() {
|
|
3629
|
+
const [badge, setBadge] = React.useState(null)
|
|
3630
|
+
const cache = React.useRef(new Map())
|
|
3631
|
+
React.useEffect(() => {
|
|
3632
|
+
let disposed = false
|
|
3633
|
+
let raf = 0
|
|
3634
|
+
const rafFn = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : ((fn) => setTimeout(fn, 16))
|
|
3635
|
+
const cancelFn = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : ((id) => clearTimeout(id))
|
|
3636
|
+
const schedule = () => {
|
|
3637
|
+
if (disposed || raf !== 0) return
|
|
3638
|
+
raf = rafFn(() => { raf = 0; tick() })
|
|
3639
|
+
}
|
|
3640
|
+
const tick = () => {
|
|
3641
|
+
try {
|
|
3642
|
+
if (typeof document === 'undefined' || typeof window === 'undefined') return
|
|
3643
|
+
const row = document.querySelector('tr[data-selected="true"][data-trajectory-row-key]')
|
|
3644
|
+
const callId = trajectoryRowCallId(row)
|
|
3645
|
+
const sessionId = currentSessionId()
|
|
3646
|
+
if (!row || callId === undefined || sessionId === undefined) {
|
|
3647
|
+
setBadge(null)
|
|
3648
|
+
return
|
|
3649
|
+
}
|
|
3650
|
+
const rect = row.getBoundingClientRect()
|
|
3651
|
+
const position = {
|
|
3652
|
+
top: Math.max(4, rect.top + 4),
|
|
3653
|
+
left: Math.max(8, Math.min(window.innerWidth - 132, rect.right - 122)),
|
|
3654
|
+
}
|
|
3655
|
+
const key = `${sessionId}|${callId}`
|
|
3656
|
+
const cached = cache.current.get(key)
|
|
3657
|
+
const now = Date.now()
|
|
3658
|
+
if (cached && cached.pending === true) return
|
|
3659
|
+
if (cached && now - cached.at < 4000) {
|
|
3660
|
+
setBadge(cached.entries.length === 0 ? null : { ...position, sessionId, callId, entries: cached.entries })
|
|
3661
|
+
return
|
|
3662
|
+
}
|
|
3663
|
+
cache.current.set(key, { at: now, pending: true, entries: [] })
|
|
3664
|
+
api(`audit?session=${encodeURIComponent(sessionId)}&operation=${encodeURIComponent(callId)}&limit=20`)
|
|
3665
|
+
.then((value) => {
|
|
3666
|
+
const entries = value && Array.isArray(value.entries) ? value.entries : []
|
|
3667
|
+
cache.current.set(key, { at: Date.now(), pending: false, entries })
|
|
3668
|
+
if (!disposed) schedule()
|
|
3669
|
+
})
|
|
3670
|
+
.catch(() => {
|
|
3671
|
+
cache.current.set(key, { at: Date.now(), pending: false, entries: [] })
|
|
3672
|
+
})
|
|
3673
|
+
} catch { /* 观察失败:保持无徽标 */ }
|
|
3674
|
+
}
|
|
3675
|
+
let observer = null
|
|
3676
|
+
try {
|
|
3677
|
+
observer = new MutationObserver(schedule)
|
|
3678
|
+
observer.observe(document.body, {
|
|
3679
|
+
childList: true,
|
|
3680
|
+
subtree: true,
|
|
3681
|
+
attributes: true,
|
|
3682
|
+
attributeFilter: ['data-selected'],
|
|
3683
|
+
})
|
|
3684
|
+
} catch { observer = null }
|
|
3685
|
+
const onScroll = () => schedule()
|
|
3686
|
+
let onResize = onScroll
|
|
3687
|
+
try {
|
|
3688
|
+
window.addEventListener('scroll', onScroll, true)
|
|
3689
|
+
window.addEventListener('resize', onResize)
|
|
3690
|
+
} catch { /* 非浏览器环境 */ }
|
|
3691
|
+
schedule()
|
|
3692
|
+
return () => {
|
|
3693
|
+
disposed = true
|
|
3694
|
+
if (raf !== 0) cancelFn(raf)
|
|
3695
|
+
try { observer?.disconnect() } catch { /* 已断开 */ }
|
|
3696
|
+
try {
|
|
3697
|
+
window.removeEventListener('scroll', onScroll, true)
|
|
3698
|
+
window.removeEventListener('resize', onResize)
|
|
3699
|
+
} catch { /* 非浏览器环境 */ }
|
|
3700
|
+
}
|
|
3701
|
+
}, [])
|
|
3702
|
+
if (badge === null) return null
|
|
3703
|
+
return h('button', {
|
|
3704
|
+
className: 'mem-traj-chip',
|
|
3705
|
+
style: { top: badge.top, left: badge.left },
|
|
3706
|
+
title: '这次工具调用有记忆审计记录;点击在记忆面板里查看',
|
|
3707
|
+
onClick: () => {
|
|
3708
|
+
openMemoryAuditPanel({
|
|
3709
|
+
sessionId: badge.sessionId,
|
|
3710
|
+
callId: badge.callId,
|
|
3711
|
+
...(badge.entries[0]?.id ? { entryId: badge.entries[0].id } : {}),
|
|
3712
|
+
})
|
|
3713
|
+
setBadge(null)
|
|
3714
|
+
},
|
|
3715
|
+
}, h('span', { className: 'dot' }), `记忆 ${badge.entries.length}`)
|
|
3716
|
+
}
|
|
3717
|
+
|
|
3718
|
+
/**
|
|
3719
|
+
* 轨迹详情面板里的「记忆审计」页签。
|
|
3720
|
+
*
|
|
3721
|
+
* Trajectory 的详情页签是包内私有的 `detailTabs` 数组,没有给插件留 slot。
|
|
3722
|
+
* 这里不在 React 管理的 `<div data-slot>` 里插节点(会被重渲染清掉),而是:
|
|
3723
|
+
* 1. 给详情页签行加 `padding-right` 预留 96px;
|
|
3724
|
+
* 2. 在 `shell.overlay` 里用 fixed 定位渲染一个页签按钮,贴在保留区;
|
|
3725
|
+
* 3. 点开后用 fixed 覆盖详情正文区域,展示这条记录的审计;
|
|
3726
|
+
* 4. 页签/面板的位置随滚动、resize、详情切换重新测量。
|
|
3727
|
+
* 选择器全部用 CSS Modules 的稳定后缀(`_details` / `_detailTabs` / `_detailBody`),
|
|
3728
|
+
* 失配时什么都不显示,不影响轨迹本身。
|
|
3729
|
+
*/
|
|
3730
|
+
function TrajectoryDetailAudit() {
|
|
3731
|
+
const [layout, setLayout] = React.useState({
|
|
3732
|
+
visible: false, tabTop: 0, tabLeft: 0, tabWidth: 88, paneTop: 0, paneLeft: 0, paneWidth: 0, paneHeight: 0,
|
|
3733
|
+
})
|
|
3734
|
+
const [open, setOpen] = React.useState(false)
|
|
3735
|
+
const [callId, setCallId] = React.useState(undefined)
|
|
3736
|
+
const [sessionId, setSessionId] = React.useState(undefined)
|
|
3737
|
+
const [entries, setEntries] = React.useState([])
|
|
3738
|
+
const [loading, setLoading] = React.useState(false)
|
|
3739
|
+
const [error, setError] = React.useState('')
|
|
3740
|
+
const layoutRef = React.useRef(layout)
|
|
3741
|
+
const openRef = React.useRef(false)
|
|
3742
|
+
const keyRef = React.useRef('')
|
|
3743
|
+
const cacheRef = React.useRef(new Map())
|
|
3744
|
+
const setOpenBoth = (value) => { openRef.current = value; setOpen(value) }
|
|
3745
|
+
|
|
3746
|
+
const loadAudit = (sid, cid) => {
|
|
3747
|
+
const key = `${sid}|${cid}`
|
|
3748
|
+
const cached = cacheRef.current.get(key)
|
|
3749
|
+
if (cached && cached.pending === true) return
|
|
3750
|
+
if (cached && Date.now() - cached.at < 4000) {
|
|
3751
|
+
setEntries(cached.entries)
|
|
3752
|
+
setLoading(false)
|
|
3753
|
+
setError('')
|
|
3754
|
+
return
|
|
3755
|
+
}
|
|
3756
|
+
cacheRef.current.set(key, { at: Date.now(), pending: true, entries: [] })
|
|
3757
|
+
setLoading(true)
|
|
3758
|
+
setError('')
|
|
3759
|
+
api(`audit?session=${encodeURIComponent(sid)}&operation=${encodeURIComponent(cid)}&limit=50`)
|
|
3760
|
+
.then((value) => {
|
|
3761
|
+
const list = value && Array.isArray(value.entries) ? value.entries : []
|
|
3762
|
+
cacheRef.current.set(key, { at: Date.now(), pending: false, entries: list })
|
|
3763
|
+
if (keyRef.current === key) { setEntries(list); setLoading(false) }
|
|
3764
|
+
})
|
|
3765
|
+
.catch((reason) => {
|
|
3766
|
+
cacheRef.current.set(key, { at: Date.now(), pending: false, entries: [] })
|
|
3767
|
+
if (keyRef.current === key) { setEntries([]); setLoading(false); setError(String(reason?.message || reason)) }
|
|
3768
|
+
})
|
|
3769
|
+
}
|
|
3770
|
+
|
|
3771
|
+
React.useEffect(() => {
|
|
3772
|
+
let disposed = false
|
|
3773
|
+
let raf = 0
|
|
3774
|
+
const rafFn = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : ((fn) => setTimeout(fn, 16))
|
|
3775
|
+
const cancelFn = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : ((id) => clearTimeout(id))
|
|
3776
|
+
const apply = (next) => {
|
|
3777
|
+
const prev = layoutRef.current
|
|
3778
|
+
if (prev.visible === next.visible
|
|
3779
|
+
&& Math.abs(prev.tabTop - next.tabTop) < 1
|
|
3780
|
+
&& Math.abs(prev.tabLeft - next.tabLeft) < 1
|
|
3781
|
+
&& Math.abs(prev.paneTop - next.paneTop) < 1
|
|
3782
|
+
&& Math.abs(prev.paneLeft - next.paneLeft) < 1
|
|
3783
|
+
&& Math.abs(prev.paneWidth - next.paneWidth) < 1
|
|
3784
|
+
&& Math.abs(prev.paneHeight - next.paneHeight) < 1) return
|
|
3785
|
+
layoutRef.current = next
|
|
3786
|
+
setLayout(next)
|
|
3787
|
+
}
|
|
3788
|
+
const hide = () => {
|
|
3789
|
+
apply({ visible: false, tabTop: 0, tabLeft: 0, tabWidth: 88, paneTop: 0, paneLeft: 0, paneWidth: 0, paneHeight: 0 })
|
|
3790
|
+
keyRef.current = ''
|
|
3791
|
+
}
|
|
3792
|
+
const tick = () => {
|
|
3793
|
+
try {
|
|
3794
|
+
if (disposed || typeof document === 'undefined' || typeof window === 'undefined') return
|
|
3795
|
+
const details = document.querySelector('[class*="_details"]')
|
|
3796
|
+
if (details === null) { hide(); return }
|
|
3797
|
+
const tabs = details.querySelector('[class*="_detailTabs"]')
|
|
3798
|
+
const body = details.querySelector('[class*="_detailBody"]')
|
|
3799
|
+
const row = document.querySelector('tr[data-selected="true"][data-trajectory-row-key]')
|
|
3800
|
+
if (tabs === null || body === null || row === null) { hide(); return }
|
|
3801
|
+
const detailsRect = details.getBoundingClientRect()
|
|
3802
|
+
const tabsRect = tabs.getBoundingClientRect()
|
|
3803
|
+
if (detailsRect.width < 220 || detailsRect.height < 120 || tabsRect.height === 0) { hide(); return }
|
|
3804
|
+
const sid = currentSessionId()
|
|
3805
|
+
if (sid === undefined) { hide(); return }
|
|
3806
|
+
// 给受 React 管理的 tabs 行留出右侧空位;只改 style,不动 DOM 结构。
|
|
3807
|
+
if (tabs.style.paddingRight !== '96px') tabs.style.paddingRight = '96px'
|
|
3808
|
+
const cid = trajectoryRowCallId(row)
|
|
3809
|
+
const key = `${sid}|${cid ?? ''}`
|
|
3810
|
+
if (key !== keyRef.current) {
|
|
3811
|
+
keyRef.current = key
|
|
3812
|
+
setCallId(cid)
|
|
3813
|
+
setSessionId(sid)
|
|
3814
|
+
setOpenBoth(false)
|
|
3815
|
+
if (cid === undefined) {
|
|
3816
|
+
setEntries([])
|
|
3817
|
+
setLoading(false)
|
|
3818
|
+
setError('')
|
|
3819
|
+
} else {
|
|
3820
|
+
loadAudit(sid, cid)
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
const tabWidth = 88
|
|
3824
|
+
const tabTop = tabsRect.top + 4
|
|
3825
|
+
const tabLeft = Math.max(0, tabsRect.right - tabWidth - 4)
|
|
3826
|
+
const paneTop = tabsRect.bottom
|
|
3827
|
+
const paneLeft = detailsRect.left
|
|
3828
|
+
const paneWidth = detailsRect.width
|
|
3829
|
+
// 轨迹会把 composer 浮在面板底部;审计面板停在 composer 上沿,
|
|
3830
|
+
// 避免把输入框盖住(composer 不存在/隐藏时退回面板底边)。
|
|
3831
|
+
const composerSeat = document.querySelector('[class*="_composerSeat"]')
|
|
3832
|
+
const composerRect = composerSeat ? composerSeat.getBoundingClientRect() : null
|
|
3833
|
+
const paneBottom = composerRect !== null && composerRect.height > 0
|
|
3834
|
+
? Math.min(detailsRect.bottom, composerRect.top)
|
|
3835
|
+
: detailsRect.bottom
|
|
3836
|
+
const paneHeight = Math.max(0, paneBottom - tabsRect.bottom)
|
|
3837
|
+
apply({ visible: true, tabTop, tabLeft, tabWidth, paneTop, paneLeft, paneWidth, paneHeight })
|
|
3838
|
+
} catch { /* 观察失败:保持现状 */ }
|
|
3839
|
+
}
|
|
3840
|
+
const schedule = () => {
|
|
3841
|
+
if (disposed || raf !== 0) return
|
|
3842
|
+
raf = rafFn(() => { raf = 0; tick() })
|
|
3843
|
+
}
|
|
3844
|
+
let observer = null
|
|
3845
|
+
try {
|
|
3846
|
+
observer = new MutationObserver(schedule)
|
|
3847
|
+
observer.observe(document.body, {
|
|
3848
|
+
childList: true,
|
|
3849
|
+
subtree: true,
|
|
3850
|
+
attributes: true,
|
|
3851
|
+
attributeFilter: ['data-selected', 'class', 'style'],
|
|
3852
|
+
})
|
|
3853
|
+
} catch { observer = null }
|
|
3854
|
+
const onScroll = () => schedule()
|
|
3855
|
+
let timer = null
|
|
3856
|
+
try {
|
|
3857
|
+
window.addEventListener('scroll', onScroll, true)
|
|
3858
|
+
window.addEventListener('resize', onScroll)
|
|
3859
|
+
timer = setInterval(tick, 700)
|
|
3860
|
+
} catch { /* 非浏览器环境 */ }
|
|
3861
|
+
const onDocClick = (event) => {
|
|
3862
|
+
try {
|
|
3863
|
+
const target = event.target
|
|
3864
|
+
if (!target || typeof target.closest !== 'function') return
|
|
3865
|
+
if (target.closest('.mem-traj-audit-tab') || target.closest('.mem-traj-audit-pane')) return
|
|
3866
|
+
if (target.closest('[class*="_detailTab"]')) setOpenBoth(false)
|
|
3867
|
+
} catch { /* 忽略 */ }
|
|
3868
|
+
}
|
|
3869
|
+
try { document.addEventListener('click', onDocClick, true) } catch { /* 忽略 */ }
|
|
3870
|
+
schedule()
|
|
3871
|
+
return () => {
|
|
3872
|
+
disposed = true
|
|
3873
|
+
if (raf !== 0) cancelFn(raf)
|
|
3874
|
+
if (timer !== null) clearInterval(timer)
|
|
3875
|
+
try { observer?.disconnect() } catch { /* 已断开 */ }
|
|
3876
|
+
try {
|
|
3877
|
+
window.removeEventListener('scroll', onScroll, true)
|
|
3878
|
+
window.removeEventListener('resize', onScroll)
|
|
3879
|
+
document.removeEventListener('click', onDocClick, true)
|
|
3880
|
+
} catch { /* 非浏览器环境 */ }
|
|
3881
|
+
}
|
|
3882
|
+
}, [])
|
|
3883
|
+
|
|
3884
|
+
if (!layout.visible) return null
|
|
3885
|
+
const toggle = () => setOpenBoth(!openRef.current)
|
|
3886
|
+
const close = () => setOpenBoth(false)
|
|
3887
|
+
const openInPanel = (entryId) => {
|
|
3888
|
+
openMemoryAuditPanel({
|
|
3889
|
+
sessionId,
|
|
3890
|
+
...(callId !== undefined ? { callId } : {}),
|
|
3891
|
+
...(entryId !== undefined ? { entryId } : {}),
|
|
3892
|
+
})
|
|
3893
|
+
}
|
|
3894
|
+
const rowView = (entry) => {
|
|
3895
|
+
const ids = entry.selected && Array.isArray(entry.selected.contentIds) ? entry.selected.contentIds : []
|
|
3896
|
+
const outcome = auditOutcomeMeta(entry.outcome)
|
|
3897
|
+
return h('button', {
|
|
3898
|
+
key: entry.id,
|
|
3899
|
+
className: 'mem-traj-audit-row',
|
|
3900
|
+
title: `${fmtTime(entry.at)} · ${entry.trigger || entry.stage || ''}`,
|
|
3901
|
+
onClick: () => openInPanel(entry.id),
|
|
3902
|
+
},
|
|
3903
|
+
h('div', { className: 'mem-traj-audit-row-top' },
|
|
3904
|
+
h('span', { className: 't' }, shortTime(entry.at)),
|
|
3905
|
+
h('span', { className: 'ch' }, `${auditChannelLabel(entry.channel)} · ${entry.kind || 'event'}`),
|
|
3906
|
+
h('span', { className: 'spacer' }),
|
|
3907
|
+
h('span', { className: `audit-pill ${outcome.tone}` }, outcome.label),
|
|
3908
|
+
),
|
|
3909
|
+
h('div', { className: 'mem-traj-audit-row-meta' },
|
|
3910
|
+
`${entry.trigger || '—'}${entry.stage ? ` / ${entry.stage}` : ''}`
|
|
3911
|
+
+ (entry.delivery ? ` · ${auditDeliveryMeta(entry).label}` : '')
|
|
3912
|
+
+ (entry.candidates !== undefined ? ` · 候选 ${entry.candidates}` : '')
|
|
3913
|
+
+ (entry.selected && entry.selected.count !== undefined ? ` · 选中 ${entry.selected.count}` : ''),
|
|
3914
|
+
),
|
|
3915
|
+
ids.length > 0
|
|
3916
|
+
? h('div', { className: 'mem-traj-audit-row-ids' },
|
|
3917
|
+
ids.slice(0, 4).map((id) => h('span', { className: 'audit-id', key: id }, String(id).length > 14 ? `${String(id).slice(0, 10)}…` : String(id))),
|
|
3918
|
+
ids.length > 4 ? h('span', { className: 'audit-id-sub' }, `+${ids.length - 4}`) : null,
|
|
3919
|
+
)
|
|
3920
|
+
: null,
|
|
3921
|
+
)
|
|
3922
|
+
}
|
|
3923
|
+
return h(React.Fragment, null,
|
|
3924
|
+
h('button', {
|
|
3925
|
+
className: 'mem-traj-audit-tab' + (open ? ' on' : ''),
|
|
3926
|
+
style: { top: layout.tabTop, left: layout.tabLeft, width: layout.tabWidth },
|
|
3927
|
+
title: callId === undefined ? '这条记录没有 callId 锚点,可打开本会话记忆审计' : `查看这次调用的记忆审计(${callId})`,
|
|
3928
|
+
onClick: toggle,
|
|
3929
|
+
}, `记忆审计${entries.length > 0 ? ` ${entries.length}` : ''}`),
|
|
3930
|
+
open
|
|
3931
|
+
? h('div', {
|
|
3932
|
+
className: 'memp mem-traj-audit-pane',
|
|
3933
|
+
style: {
|
|
3934
|
+
top: layout.paneTop,
|
|
3935
|
+
left: layout.paneLeft,
|
|
3936
|
+
width: layout.paneWidth,
|
|
3937
|
+
height: layout.paneHeight,
|
|
3938
|
+
},
|
|
3939
|
+
},
|
|
3940
|
+
h('div', { className: 'mem-traj-audit-pane-head' },
|
|
3941
|
+
h('b', null, '记忆审计'),
|
|
3942
|
+
callId !== undefined ? h('span', { className: 'mono', title: callId }, callId.length > 20 ? `${callId.slice(0, 18)}…` : callId) : null,
|
|
3943
|
+
h('span', { className: 'spacer' }),
|
|
3944
|
+
h('button', { className: 'linkbtn', onClick: close }, '返回轨迹'),
|
|
3945
|
+
),
|
|
3946
|
+
h('div', { className: 'mem-traj-audit-pane-body' },
|
|
3947
|
+
loading
|
|
3948
|
+
? h('div', { className: 'mem-traj-audit-empty' }, '加载审计…')
|
|
3949
|
+
: error
|
|
3950
|
+
? h('div', { className: 'mem-traj-audit-empty' }, `加载失败:${error}`)
|
|
3951
|
+
: entries.length === 0
|
|
3952
|
+
? h('div', { className: 'mem-traj-audit-empty' },
|
|
3953
|
+
callId === undefined
|
|
3954
|
+
? '这条轨迹记录没有 callId 锚点,无法精确过滤;可以打开本会话记忆审计,按轮次/步骤查找。'
|
|
3955
|
+
: '这次调用没有记忆审计记录(可能发生在审计开启前,或已被容量策略淘汰)。',
|
|
3956
|
+
)
|
|
3957
|
+
: entries.map(rowView),
|
|
3958
|
+
),
|
|
3959
|
+
h('div', { className: 'mem-traj-audit-pane-foot' },
|
|
3960
|
+
h('span', { className: 'muted' }, entries.length > 0 ? `${entries.length} 条` : ''),
|
|
3961
|
+
h('span', { className: 'spacer' }),
|
|
3962
|
+
h('button', { onClick: () => openInPanel(entries[0]?.id) }, '打开本会话记忆审计'),
|
|
3963
|
+
),
|
|
3964
|
+
)
|
|
3965
|
+
: null,
|
|
3966
|
+
)
|
|
3967
|
+
}
|
|
3968
|
+
|
|
3218
3969
|
const inject = ['slots']
|
|
3219
3970
|
|
|
3220
3971
|
/** 侧栏入口打开的主界面页面(整块可滚动,内容就是面板本体)。 */
|
|
3221
|
-
function MemoryPage({ openSession, sessionInfo } = {}) {
|
|
3972
|
+
function MemoryPage({ openSession, sessionInfo, openTrajectory } = {}) {
|
|
3222
3973
|
return h('div', { className: 'mem-page' },
|
|
3223
3974
|
h('div', { className: 'mem-page-head' }, h('h2', null, '记忆系统')),
|
|
3224
|
-
h(MemoryPanel, { openSession, sessionInfo }),
|
|
3975
|
+
h(MemoryPanel, { openSession, sessionInfo, openTrajectory, audience: 'panel' }),
|
|
3225
3976
|
)
|
|
3226
3977
|
}
|
|
3227
3978
|
|
|
@@ -3264,6 +4015,7 @@ window.__ModuleLoader__.load({
|
|
|
3264
4015
|
|
|
3265
4016
|
const slots = ctx.get('slots')
|
|
3266
4017
|
if (slots === undefined) return
|
|
4018
|
+
clientCtx = ctx
|
|
3267
4019
|
|
|
3268
4020
|
/** 宿主 uiWorkspace 服务:打开会话 / 读取会话摘要(旧宿主缺失时静默降级)。 */
|
|
3269
4021
|
const workspaceService = () => {
|
|
@@ -3297,7 +4049,12 @@ window.__ModuleLoader__.load({
|
|
|
3297
4049
|
|
|
3298
4050
|
slots.inject('settings.section', () => slots.register(
|
|
3299
4051
|
{ name: 'settings.section', id: 'memory', order: 24, label: NAV_LABEL },
|
|
3300
|
-
() => React.createElement(MemoryPanel, {
|
|
4052
|
+
() => React.createElement(MemoryPanel, {
|
|
4053
|
+
openSession,
|
|
4054
|
+
sessionInfo,
|
|
4055
|
+
audience: 'panel',
|
|
4056
|
+
openTrajectory: jumpAuditEntryToTrajectory,
|
|
4057
|
+
}),
|
|
3301
4058
|
))
|
|
3302
4059
|
|
|
3303
4060
|
// 侧栏入口(可选):开启后在左侧栏「插件」下方多一个「记忆系统」,点击在主界面打开面板。
|
|
@@ -3316,7 +4073,11 @@ window.__ModuleLoader__.load({
|
|
|
3316
4073
|
}
|
|
3317
4074
|
try {
|
|
3318
4075
|
sidebarDisposers = [
|
|
3319
|
-
slots.inject('main', () => slots.register({ name: 'main', key: 'memory' }, () => React.createElement(MemoryPage, {
|
|
4076
|
+
slots.inject('main', () => slots.register({ name: 'main', key: 'memory' }, () => React.createElement(MemoryPage, {
|
|
4077
|
+
openSession,
|
|
4078
|
+
sessionInfo,
|
|
4079
|
+
openTrajectory: jumpAuditEntryToTrajectory,
|
|
4080
|
+
}))),
|
|
3320
4081
|
slots.inject('sidebar.panellist', () => slots.register(
|
|
3321
4082
|
{ name: 'sidebar.panellist', id: 'memory', order: 20, label: () => NAV_LABEL },
|
|
3322
4083
|
() => React.createElement(NavLineIcon),
|
|
@@ -3333,6 +4094,39 @@ window.__ModuleLoader__.load({
|
|
|
3333
4094
|
window.addEventListener('dsh-memory:settings', syncSidebar)
|
|
3334
4095
|
ctx.effect(() => () => window.removeEventListener('dsh-memory:settings', syncSidebar), 'dsh-memory: sidebar entry')
|
|
3335
4096
|
}
|
|
4097
|
+
|
|
4098
|
+
// ===== 会话轨迹 / 视图环 / 浮层集成 =====
|
|
4099
|
+
// 每一条都单独兜底:宿主没有这个槽(旧版本/精简组合)时只是少一个入口,
|
|
4100
|
+
// 绝不能让整个 client apply 失败。
|
|
4101
|
+
try {
|
|
4102
|
+
slots.inject('conversation.view', () => slots.register({
|
|
4103
|
+
name: 'conversation.view',
|
|
4104
|
+
id: 'memory',
|
|
4105
|
+
order: 20,
|
|
4106
|
+
label: () => '记忆',
|
|
4107
|
+
inject: (sessionId) => ({ sessionId, sessionInfo }),
|
|
4108
|
+
}, MemoryAuditView))
|
|
4109
|
+
} catch (error) {
|
|
4110
|
+
console.warn('[dsh-memory] 记忆审计视图注册失败:', error?.message)
|
|
4111
|
+
}
|
|
4112
|
+
try {
|
|
4113
|
+
slots.inject('shell.overlay', () => slots.register({
|
|
4114
|
+
name: 'shell.overlay',
|
|
4115
|
+
id: 'memory-audit-badge',
|
|
4116
|
+
order: 60,
|
|
4117
|
+
}, () => React.createElement(TrajectoryMemoryBadge)))
|
|
4118
|
+
} catch (error) {
|
|
4119
|
+
console.warn('[dsh-memory] 轨迹记忆徽标注册失败:', error?.message)
|
|
4120
|
+
}
|
|
4121
|
+
try {
|
|
4122
|
+
slots.inject('shell.overlay', () => slots.register({
|
|
4123
|
+
name: 'shell.overlay',
|
|
4124
|
+
id: 'memory-audit-detail',
|
|
4125
|
+
order: 61,
|
|
4126
|
+
}, () => React.createElement(TrajectoryDetailAudit)))
|
|
4127
|
+
} catch (error) {
|
|
4128
|
+
console.warn('[dsh-memory] 轨迹详情记忆页签注册失败:', error?.message)
|
|
4129
|
+
}
|
|
3336
4130
|
} catch (error) {
|
|
3337
4131
|
console.error('[dsh-memory] client apply 失败(已吞掉):', error?.message)
|
|
3338
4132
|
}
|
|
@@ -3458,6 +4252,17 @@ window.__ModuleLoader__.load({
|
|
|
3458
4252
|
NavLineIcon: NavLineIcon,
|
|
3459
4253
|
NAV_DOM: NAV_DOM,
|
|
3460
4254
|
paintNavIcon: paintNavIcon,
|
|
4255
|
+
// 审计 ↔ 轨迹桥(测试只覆盖纯解析/焦点总线,不碰宿主 slot 实例)
|
|
4256
|
+
MemoryAuditView: MemoryAuditView,
|
|
4257
|
+
TrajectoryMemoryBadge: TrajectoryMemoryBadge,
|
|
4258
|
+
TrajectoryDetailAudit: TrajectoryDetailAudit,
|
|
4259
|
+
auditEntryCallId: auditEntryCallId,
|
|
4260
|
+
trajectoryRowCallId: trajectoryRowCallId,
|
|
4261
|
+
requestAuditFocus: requestAuditFocus,
|
|
4262
|
+
takeAuditFocus: takeAuditFocus,
|
|
4263
|
+
conversationStoreFor: conversationStoreFor,
|
|
4264
|
+
setConversationView: setConversationView,
|
|
4265
|
+
setClientCtx: (value) => { clientCtx = value },
|
|
3461
4266
|
}
|
|
3462
4267
|
return module.exports
|
|
3463
4268
|
},
|