sync update from LAN repo (source dhk-1 @ 3b1ec5b4)

This commit is contained in:
gozeros committed 2026-11-05 10:56:34 +08:00
1 parent da6521b6cb
commit 264e2200d6
995 files changed
+148105 -13399

No files matched your search

@@ -30,6 +30,23 @@ class LlmWikiIndexStore(ABC):
return []
async def list_pages(
self,
mapping_ids: list[str],
*,
limit: int = 500,
include_drafts: bool = False,
) -> list[dict[str, Any]]:
"""Return a bounded, newest-first Wiki page snapshot.
Smart-reasoning regex search applies its expression in Python so the
behavior stays identical on SQLite, MySQL and GaussDB. Third-party
stores may keep the empty default; the tool then uses the remote Wiki
API fallback.
"""
return []
async def replace_graph_edges(
self,
mapping_id: str,
@@ -72,6 +72,28 @@ class MemoryLlmWikiIndexStore(LlmWikiIndexStore):
break
return rows
async def list_pages(
self,
mapping_ids: list[str],
*,
limit: int = 500,
include_drafts: bool = False,
) -> list[dict[str, Any]]:
wanted = {str(item).strip() for item in mapping_ids if str(item).strip()}
cap = max(1, min(int(limit), 2000))
rows = [
dict(page)
for page in self.pages.values()
if page.get("knowledge_base_mapping_id") in wanted
and not page.get("is_remote_deleted")
and page.get("status") in ({"published", "draft"} if include_drafts else {"published"})
]
rows.sort(
key=lambda page: str(page.get("remote_updated_at") or page.get("updated_at") or ""),
reverse=True,
)
return rows[:cap]
async def replace_graph_edges(
self,
mapping_id: str,
@@ -123,6 +123,35 @@ class SqlLlmWikiIndexStore(LlmWikiIndexStore):
async with self._sf() as session:
return [_dict(row) for row in (await session.execute(stmt)).scalars()]
async def list_pages(
self,
mapping_ids: list[str],
*,
limit: int = 500,
include_drafts: bool = False,
) -> list[dict[str, Any]]:
normalized_ids = list(
dict.fromkeys(str(item).strip() for item in mapping_ids if str(item).strip())
)
if not normalized_ids:
return []
statuses = ["published", "draft"] if include_drafts else ["published"]
stmt = (
select(LlmWikiWikiPageRow)
.where(
LlmWikiWikiPageRow.knowledge_base_mapping_id.in_(normalized_ids),
LlmWikiWikiPageRow.is_remote_deleted.is_(False),
LlmWikiWikiPageRow.status.in_(statuses),
)
.order_by(
LlmWikiWikiPageRow.remote_updated_at.desc(),
LlmWikiWikiPageRow.updated_at.desc(),
)
.limit(max(1, min(int(limit), 2000)))
)
async with self._sf() as session:
return [_dict(row) for row in (await session.execute(stmt)).scalars()]
async def replace_graph_edges(
self,
mapping_id: str,