feat(rag): align LightRAG native citations and MCP bridge

This commit is contained in:
lix-2026
2026-06-09 09:20:56 +08:00
parent 0e8b03daf8
commit 8e3be8b0b7
39 changed files with 2255 additions and 2732 deletions
-84
View File
@@ -118,63 +118,6 @@ pub const DOC_TOOL_FIND: ToolSpec = ToolSpec {
input_schema_json: r#"{"type":"object","required":["query"],"properties":{"query":{"type":"string"},"maxResults":{"type":"integer","minimum":1,"maximum":30}}}"#,
};
pub const DOCS_TOOL_SEARCH: ToolSpec = ToolSpec {
name: "docs_search",
display_name: "跨页文档搜索",
description: "在工作区内搜索文档标题、正文、导图、表格与 OCR 结果。",
toolset_id: "toolset.docs_read",
invocation_kind: InvocationKind::Query,
effect: ToolEffect::Read,
requires_confirmation: false,
input_schema_json: r#"{"type":"object","required":["query"],"properties":{"query":{"type":"string"},"workspaceId":{"type":"string"},"limit":{"type":"integer","minimum":1,"maximum":30},"includeDeleted":{"type":"boolean"},"pageId":{"type":"string"},"titleOnly":{"type":"boolean"},"exact":{"type":"boolean"},"includeOcr":{"type":"boolean"},"timeRange":{"type":"string"},"timeField":{"type":"string"},"customRangeFrom":{"type":"string"},"customRangeTo":{"type":"string"}}}"#,
};
pub const DOCS_TOOL_READ: ToolSpec = ToolSpec {
name: "docs_read",
display_name: "跨页文档读取",
description: "读取指定文档的标题、正文摘要与可选 content 快照。",
toolset_id: "toolset.docs_read",
invocation_kind: InvocationKind::Query,
effect: ToolEffect::Read,
requires_confirmation: false,
input_schema_json: r#"{"type":"object","required":["documentId"],"properties":{"documentId":{"type":"string"},"maxChars":{"type":"integer","minimum":200,"maximum":20000},"includeContent":{"type":"boolean"}}}"#,
};
pub const EVIDENCE_TOOL_SEARCH: ToolSpec = ToolSpec {
name: "mnote.evidence.search",
display_name: "证据搜索",
description:
"在工作区内搜索可回跳原文的证据块,返回 quote、locator、openAction 与 citationMarkdown。",
toolset_id: "toolset.evidence_read",
invocation_kind: InvocationKind::Query,
effect: ToolEffect::Read,
requires_confirmation: false,
input_schema_json: r#"{"type":"object","required":["query","scope"],"properties":{"query":{"type":"string"},"scope":{"type":"object","required":["workspaceId","rootUri"],"properties":{"workspaceId":{"type":"string"},"rootUri":{"type":"string"},"targetDocumentId":{"type":"string"},"includeResources":{"type":"boolean"},"includeOcr":{"type":"boolean"}}},"mode":{"enum":["keyword","tree","hybrid","graph"]},"topK":{"type":"integer","minimum":1,"maximum":30}}}"#,
};
pub const EVIDENCE_TOOL_READ: ToolSpec = ToolSpec {
name: "mnote.evidence.read",
display_name: "证据读回",
description:
"按 EvidenceLocator 读取原文证据及周边上下文,供 AI 回答引用,并返回可点击引用链接。",
toolset_id: "toolset.evidence_read",
invocation_kind: InvocationKind::Query,
effect: ToolEffect::Read,
requires_confirmation: false,
input_schema_json: r#"{"type":"object","required":["locator"],"properties":{"locator":{"type":"object"},"context":{"type":"object","properties":{"beforeBlocks":{"type":"integer","minimum":0,"maximum":20},"afterBlocks":{"type":"integer","minimum":0,"maximum":20},"includeSectionSummary":{"type":"boolean"}}}}}"#,
};
pub const EVIDENCE_TOOL_OPEN: ToolSpec = ToolSpec {
name: "mnote.evidence.open",
display_name: "证据打开",
description: "把 EvidenceLocator 归一化为 MNote 可执行的打开/定位动作,并返回 citationUrl/citationMarkdown。",
toolset_id: "toolset.evidence_read",
invocation_kind: InvocationKind::Query,
effect: ToolEffect::Read,
requires_confirmation: false,
input_schema_json: r#"{"type":"object","required":["locator"],"properties":{"locator":{"type":"object"}}}"#,
};
pub const IMAGE_READ_TOOL: ToolSpec = ToolSpec {
name: "image_read",
display_name: "读取图片",
@@ -414,26 +357,6 @@ pub const DOC_TOOLSET_READ: ToolSetSpec = ToolSetSpec {
tool_names: &["doc_get", "doc_find"],
};
pub const DOCS_TOOLSET_READ: ToolSetSpec = ToolSetSpec {
id: "toolset.docs_read",
display_name: "跨页文档读取",
description: "跨页面搜索与读取文档的工具集合。",
write_toolset: false,
tool_names: &["docs_search", "docs_read"],
};
pub const EVIDENCE_TOOLSET_READ: ToolSetSpec = ToolSetSpec {
id: "toolset.evidence_read",
display_name: "证据读取",
description: "搜索、读回和打开可定位原文证据的只读工具集合。",
write_toolset: false,
tool_names: &[
"mnote.evidence.search",
"mnote.evidence.read",
"mnote.evidence.open",
],
};
pub const READONLY_TOOLSET: ToolSetSpec = ToolSetSpec {
id: "toolset.readonly",
display_name: "只读工具",
@@ -527,8 +450,6 @@ pub const DOC_TOOL_REGISTRY: ToolRegistry = ToolRegistry::new(
READONLY_TOOLSET,
MEDIA_TOOLSET,
SLASH_TOOLSET_WRITE,
DOCS_TOOLSET_READ,
EVIDENCE_TOOLSET_READ,
DOC_TOOLSET_READ,
DOC_TOOLSET_WRITE,
MINDMAP_TOOLSET_READ,
@@ -541,11 +462,6 @@ pub const DOC_TOOL_REGISTRY: ToolRegistry = ToolRegistry::new(
SEARCH_WEB_TOOL,
DOC_TOOL_GET,
DOC_TOOL_FIND,
DOCS_TOOL_SEARCH,
DOCS_TOOL_READ,
EVIDENCE_TOOL_SEARCH,
EVIDENCE_TOOL_READ,
EVIDENCE_TOOL_OPEN,
IMAGE_READ_TOOL,
DOC_TOOL_INSERT_BLOCKS,
DOC_TOOL_REPLACE_RANGE,