feat(authority): export diagnostics bundle

This commit is contained in:
Youzini-afk
2026-04-28 15:15:59 +08:00
parent 6693a036dd
commit 217573e8bb
7 changed files with 625 additions and 0 deletions

View File

@@ -490,6 +490,10 @@
<i class="fa-solid fa-box-archive"></i>
<span>压实主 Sidecar</span>
</button>
<button class="bme-action-btn" id="bme-act-export-diagnostics" type="button">
<i class="fa-solid fa-file-waveform"></i>
<span>导出诊断包</span>
</button>
</div>
<div class="bme-action-group-extra">
<div class="bme-config-help" id="bme-actions-persist-repair-help"></div>

View File

@@ -6087,6 +6087,7 @@ function _bindActions() {
"bme-act-rebuild-luker-cache": "rebuildLukerLocalCache",
"bme-act-repair-luker-sidecar": "repairLukerSidecar",
"bme-act-compact-luker-sidecar": "compactLukerSidecar",
"bme-act-export-diagnostics": "exportDiagnosticsBundle",
"bme-act-export": "export",
"bme-act-import": "import",
"bme-act-rebuild": "rebuild",
@@ -6116,6 +6117,7 @@ function _bindActions() {
rebuildLukerLocalCache: "重建本地缓存",
repairLukerSidecar: "修复主 Sidecar",
compactLukerSidecar: "压实主 Sidecar",
exportDiagnosticsBundle: "导出诊断包",
rebuildSummaryState: "重建总结状态",
export: "导出图谱",
import: "导入图谱",

View File

@@ -1321,6 +1321,58 @@ export async function onDeleteCurrentIdbController(runtime) {
return { handledToast: true };
}
export async function onExportDiagnosticsBundleController(runtime) {
const chatId = runtime.getCurrentChatId?.();
if (!chatId) {
runtime.toastr.warning("当前没有聊天上下文");
return { handledToast: true };
}
if (typeof runtime.exportDiagnosticsBundle !== "function") {
runtime.toastr.info("当前运行时没有接入诊断包导出入口");
return { handledToast: true, result: { ok: false, reason: "missing-export-hook" } };
}
updateManualActionUiState(
runtime,
"导出诊断包中",
"正在收集运行时与持久化快照,并写入 Authority Blob",
"running",
);
try {
const result = await runtime.exportDiagnosticsBundle({
chatId,
reason: "manual-diagnostics-bundle",
refreshHost: true,
});
if (result?.ok) {
updateManualActionUiState(
runtime,
"诊断包已导出",
result?.path || "Authority Blob",
"success",
);
runtime.toastr.success(`诊断包已写入: ${result?.path || "Authority Blob"}`);
} else {
const reason = String(result?.reason || "authority-diagnostics-unavailable");
updateManualActionUiState(runtime, "诊断包未导出", reason, "idle");
runtime.toastr.info(`诊断包未导出: ${reason}`);
}
return { handledToast: true, result };
} catch (error) {
const message = error?.message || String(error) || "未知错误";
updateManualActionUiState(runtime, "诊断包导出失败", message, "error");
runtime.toastr.error(`诊断包导出失败: ${message}`);
return {
handledToast: true,
result: {
ok: false,
reason: "authority-diagnostics-bundle-error",
error,
},
};
}
}
export async function onDeleteAllIdbController(runtime) {
const userInput = runtime.prompt(
"此操作会删除所有聊天的 BME 本地图谱存储IndexedDB / OPFS不影响 Luker 侧车主存储。\n\n请输入 DELETE 确认:",

View File

@@ -164,6 +164,10 @@ export function createGraphPersistenceState() {
authorityLastBlobReason: "",
authorityLastBlobError: "",
authorityLastBlobUpdatedAt: "",
authorityDiagnosticsBundlePath: "",
authorityDiagnosticsBundleReason: "",
authorityDiagnosticsBundleUpdatedAt: "",
authorityDiagnosticsBundleSize: 0,
localStoreFormatVersion: 1,
localStoreMigrationState: "idle",
opfsWriteLockState: {