feat(rag): replace LiteParse flows with LightRAG provider

This commit is contained in:
lix-2026
2026-06-07 01:10:31 +08:00
parent f46c2fb5d0
commit 1f25364374
40 changed files with 7232 additions and 2350 deletions
@@ -443,43 +443,7 @@ export function createSidebarPageAiTargetRuntime(context) {
}
async function fetchPageAiOcrSidecarContext(editorTarget) {
if (currentSourceKind() !== 'local_folder') return null;
var target = editorTarget && typeof editorTarget === 'object' ? editorTarget : {};
var workspacePath = target.workspacePath && typeof target.workspacePath === 'object' ? target.workspacePath : {};
var relativePath = String(workspacePath.relativePath || target.path || '').trim();
var resourceKind = String(target.resourceKind || target.editorKind || workspacePath.resourceKind || '').trim();
if (!relativePath || !pageAiOcrEligiblePath(relativePath) || !pageAiOcrEligibleResourceKind(resourceKind)) return null;
var rootUri = String(workspacePath.rootUri || currentRootUri() || '').trim();
if (!rootUri) return null;
try {
var statusUrl = new URL('/api/local-folder/ocr/status', window.location.origin);
statusUrl.searchParams.set('rootUri', rootUri);
statusUrl.searchParams.set('sourceRootRelativePath', relativePath);
var statusResponse = await fetch(statusUrl.toString(), { cache: 'no-store', headers: { accept: 'application/json' } });
var statusPayload = await statusResponse.json().catch(function() { return null; });
var job = statusResponse.ok && statusPayload && statusPayload.ok === true ? statusPayload.job : null;
var ocrPath = String(job && job.ocrRootRelativePath || '').trim();
if (!ocrPath || String(job.status || '') === 'failed') return null;
var readUrl = new URL('/api/local-folder/ocr/read', window.location.origin);
readUrl.searchParams.set('rootUri', rootUri);
readUrl.searchParams.set('ocrRootRelativePath', ocrPath);
var readResponse = await fetch(readUrl.toString(), { cache: 'no-store', headers: { accept: 'application/json' } });
var readPayload = await readResponse.json().catch(function() { return null; });
if (!readResponse.ok || !readPayload || readPayload.ok !== true) return null;
return {
schema: 'mnote.local_ocr_context.v1',
source: 'local_ocr_sidecar',
sourceRootRelativePath: relativePath,
ocrRootRelativePath: ocrPath,
status: String(job.status || ''),
stale: job.stale === true,
provider: String(job.provider || ''),
modelVersion: String(job.modelVersion || ''),
plainTextPreview: pageAiOcrBodyPreview(readPayload.markdown || ''),
};
} catch (_) {
return null;
}
return null;
}
async function pageAiEnrichOcrContextRefs(contextRefs, agentTargetPackage, editorTarget) {