Merge branch 'main' into main

This commit is contained in:
Hao19911125
2026-04-10 18:43:42 +08:00
committed by GitHub
11 changed files with 1103 additions and 76 deletions

View File

@@ -324,8 +324,8 @@
</div>
<div class="bme-action-grid">
<button class="bme-action-btn" id="bme-act-extract" type="button">
<i class="fa-solid fa-download"></i>
<span>手动提取</span>
<i class="fa-solid fa-rotate"></i>
<span>重新提取</span>
</button>
<button class="bme-action-btn" id="bme-act-compress" type="button">
<i class="fa-solid fa-compress"></i>
@@ -359,25 +359,71 @@
<i class="fa-solid fa-rotate-left"></i>
<span>撤销最近维护</span>
</button>
<button class="bme-action-btn" id="bme-act-reroll" type="button">
<i class="fa-solid fa-rotate"></i>
<span>重新提取</span>
</button>
</div>
<div class="bme-action-group-extra">
<div class="bme-config-help">
重新提取:回滚指定楼层及之后的提取结果并重做。留空则只重做最新 AI 楼
重新提取:按总楼层计数(用户+AI首条 greeting 为 0。真正 system 不计入,且不受隐藏助手影响
</div>
<div class="bme-config-row">
<label for="bme-reroll-floor">起始楼层</label>
<input
id="bme-reroll-floor"
class="bme-config-input"
type="number"
min="0"
max="999999"
placeholder="留空 = 最新 AI 楼"
/>
<div class="bme-action-range-row">
<div class="bme-config-row">
<label for="bme-extract-mode">提取模式</label>
<select id="bme-extract-mode" class="bme-config-select">
<option value="pending">提取未处理</option>
<option value="rerun">重新提取范围</option>
</select>
</div>
<div class="bme-config-row">
<label for="bme-extract-start-floor">起始楼层</label>
<input
id="bme-extract-start-floor"
class="bme-config-input"
type="number"
min="0"
max="999999"
placeholder="留空 = 当前重提"
/>
</div>
<div class="bme-config-row">
<label for="bme-extract-end-floor">终止楼层</label>
<input
id="bme-extract-end-floor"
class="bme-config-input"
type="number"
min="0"
max="999999"
placeholder="留空 = 到最新"
/>
</div>
</div>
<div class="bme-config-help" style="margin-top:8px">
重新提取范围:起始/终止都留空 = 当前重提;只填起始 = 从起始到最新。
</div>
<div class="bme-config-help" style="margin-top:12px">
重建总结状态:默认按当前总结相关范围重建;填写楼层后按范围重建。
</div>
<div class="bme-action-range-row">
<div class="bme-config-row">
<label for="bme-summary-rebuild-start-floor">总结起始楼层</label>
<input
id="bme-summary-rebuild-start-floor"
class="bme-config-input"
type="number"
min="0"
max="999999"
placeholder="留空 = 当前重建"
/>
</div>
<div class="bme-config-row">
<label for="bme-summary-rebuild-end-floor">总结终止楼层</label>
<input
id="bme-summary-rebuild-end-floor"
class="bme-config-input"
type="number"
min="0"
max="999999"
placeholder="留空 = 到最新"
/>
</div>
</div>
</div>
</div>
@@ -1397,7 +1443,7 @@
<span>自动提取晚一楼</span>
</label>
<div class="bme-config-help">
开启后,最新 AI 楼先不自动提取,要等下一条 AI 楼出现后,才提取前一批内容。手动提取和重 Roll 不受影响。
开启后,最新 AI 楼先不自动提取,要等下一条 AI 楼出现后,才提取前一批内容。提取未处理和范围重提不受影响。
</div>
</div>
</div>

View File

@@ -112,7 +112,6 @@ const GRAPH_WRITE_ACTION_IDS = [
"bme-act-vector-rebuild",
"bme-act-vector-range",
"bme-act-vector-reembed",
"bme-act-reroll",
"bme-detail-delete",
"bme-detail-save",
"bme-cog-region-apply",
@@ -857,11 +856,11 @@ function _onFabSingleClick() {
}
async function _onFabDoubleClick() {
if (!_actionHandlers.reroll) return;
if (!_actionHandlers.extractTask) return;
try {
_fabEl?.setAttribute("data-status", "running");
await _actionHandlers.reroll({});
await _actionHandlers.extractTask({ mode: "rerun" });
_fabEl?.setAttribute("data-status", "success");
_refreshDashboard();
_refreshGraph();
@@ -870,7 +869,7 @@ async function _onFabDoubleClick() {
_fabEl?.setAttribute("data-status", status.status || "idle");
}, 3000);
} catch (err) {
console.error("[ST-BME] FAB reroll failed:", err);
console.error("[ST-BME] FAB extract task failed:", err);
_fabEl?.setAttribute("data-status", "error");
}
}
@@ -1725,7 +1724,11 @@ function _refreshMobileCognition() {
}
function _formatSummaryEntryCard(entry = {}) {
const messageRange = Array.isArray(entry?.messageRange) ? entry.messageRange : ["?", "?"];
const messageRange = Array.isArray(entry?.dialogueRange)
? entry.dialogueRange
: Array.isArray(entry?.messageRange)
? entry.messageRange
: ["?", "?"];
const extractionRange = Array.isArray(entry?.extractionRange)
? entry.extractionRange
: ["?", "?"];
@@ -3736,12 +3739,10 @@ function _bindDashboardControls() {
function _bindActions() {
const bindings = {
"bme-act-extract": "extract",
"bme-act-compress": "compress",
"bme-act-sleep": "sleep",
"bme-act-synopsis": "synopsis",
"bme-act-summary-rollup": "summaryRollup",
"bme-act-summary-rebuild": "rebuildSummaryState",
"bme-act-summary-clear": "clearSummaryState",
"bme-act-export": "export",
"bme-act-import": "import",
@@ -3763,7 +3764,6 @@ function _bindActions() {
};
const actionLabels = {
extract: "手动提取",
compress: "手动压缩",
sleep: "执行遗忘",
synopsis: "生成小总结",
@@ -3852,6 +3852,67 @@ function _bindActions() {
});
}
document
.getElementById("bme-act-extract")
?.addEventListener("click", async () => {
const btn = document.getElementById("bme-act-extract");
if (btn?.disabled) return;
const mode =
String(document.getElementById("bme-extract-mode")?.value || "pending")
.trim()
.toLowerCase() === "rerun"
? "rerun"
: "pending";
const startFloor = _parseOptionalInt(
document.getElementById("bme-extract-start-floor")?.value,
);
const endFloor = _parseOptionalInt(
document.getElementById("bme-extract-end-floor")?.value,
);
const desc =
mode === "pending"
? "提取当前尚未处理的内容"
: Number.isFinite(startFloor) || Number.isFinite(endFloor)
? `重提范围 ${Number.isFinite(startFloor) ? startFloor : "当前"} ~ ${Number.isFinite(endFloor) ? endFloor : "最新"}`
: "当前重提";
if (!confirm(`确认要执行吗?\n\n${desc}`)) {
return;
}
if (btn) {
btn.disabled = true;
btn.style.opacity = "0.5";
}
_showActionProgressUi("重新提取");
try {
await _actionHandlers.extractTask?.({
mode,
startFloor: Number.isFinite(startFloor) ? startFloor : undefined,
endFloor: Number.isFinite(endFloor) ? endFloor : undefined,
});
_refreshDashboard();
_refreshGraph();
if (
document
.getElementById("bme-pane-memory")
?.classList.contains("active")
) {
_refreshMemoryBrowser();
}
} catch (error) {
console.error("[ST-BME] Action extractTask failed:", error);
toastr.error(`重新提取失败: ${error?.message || error}`, "ST-BME");
} finally {
if (btn) {
btn.style.opacity = "";
}
_refreshRuntimeStatus();
_refreshGraphAvailabilityState();
}
});
document
.getElementById("bme-act-vector-range")
?.addEventListener("click", async () => {
@@ -3892,32 +3953,31 @@ function _bindActions() {
}
});
// 重新提取 (reroll) 绑定
document
.getElementById("bme-act-reroll")
.getElementById("bme-act-summary-rebuild")
?.addEventListener("click", async () => {
const btn = document.getElementById("bme-act-reroll");
const btn = document.getElementById("bme-act-summary-rebuild");
if (btn?.disabled) return;
const floorStr = document.getElementById("bme-reroll-floor")?.value;
const fromFloor = _parseOptionalInt(floorStr);
const desc = Number.isFinite(fromFloor)
? `从楼层 ${fromFloor} 开始回滚并重新提取`
: "回滚最新 AI 楼并重新提取";
if (!confirm(`确认要重新提取吗?\n\n${desc}\n\n已提取的记忆节点将被回滚。`)) {
return;
}
const startFloor = _parseOptionalInt(
document.getElementById("bme-summary-rebuild-start-floor")?.value,
);
const endFloor = _parseOptionalInt(
document.getElementById("bme-summary-rebuild-end-floor")?.value,
);
const desc = Number.isFinite(startFloor) || Number.isFinite(endFloor)
? `按范围 ${Number.isFinite(startFloor) ? startFloor : "当前"} ~ ${Number.isFinite(endFloor) ? endFloor : "最新"} 重建总结状态`
: "按当前总结相关范围重建总结状态";
if (btn) {
btn.disabled = true;
btn.style.opacity = "0.5";
}
_showActionProgressUi("重新提取");
_showActionProgressUi("重建总结状态");
try {
await _actionHandlers.reroll?.({
fromFloor: Number.isFinite(fromFloor) ? fromFloor : undefined,
await _actionHandlers.rebuildSummaryState?.({
startFloor: Number.isFinite(startFloor) ? startFloor : undefined,
endFloor: Number.isFinite(endFloor) ? endFloor : undefined,
});
_refreshDashboard();
_refreshGraph();
@@ -3929,8 +3989,8 @@ function _bindActions() {
_refreshMemoryBrowser();
}
} catch (error) {
console.error("[ST-BME] Action reroll failed:", error);
toastr.error(`新提取失败: ${error?.message || error}`, "ST-BME");
console.error("[ST-BME] Action rebuildSummaryState failed:", error);
toastr.error(`建总结状态失败: ${error?.message || error}`, "ST-BME");
} finally {
if (btn) {
btn.style.opacity = "";

View File

@@ -771,11 +771,21 @@ export async function onManualSummaryRollupController(runtime) {
}
}
export async function onRebuildSummaryStateController(runtime) {
export async function onRebuildSummaryStateController(runtime, options = {}) {
const graph = runtime.getCurrentGraph();
if (!graph) return;
if (!runtime.ensureGraphMutationReady("重建总结状态")) return;
updateManualActionUiState(runtime, "重建总结中", "正在按现有提取批次重建总结链", "running");
const hasStart = Number.isFinite(Number(options?.startFloor));
const hasEnd = Number.isFinite(Number(options?.endFloor));
const mode = hasStart || hasEnd ? "range" : "current";
updateManualActionUiState(
runtime,
"重建总结中",
mode === "range"
? `正在按范围 ${hasStart ? Number(options.startFloor) : "?"} ~ ${hasEnd ? Number(options.endFloor) : "最新"} 重建总结链`
: "正在重建当前总结相关范围",
"running",
);
try {
const chat = runtime.getContext?.()?.chat;
@@ -783,6 +793,9 @@ export async function onRebuildSummaryStateController(runtime) {
graph,
chat: Array.isArray(chat) ? chat : [],
settings: runtime.getSettings(),
mode,
startFloor: hasStart ? Number(options.startFloor) : null,
endFloor: hasEnd ? Number(options.endFloor) : null,
});
runtime.saveGraphToChat?.({ reason: "rebuild-summary-state" });
runtime.refreshPanelLiveState?.();