feat: 深度研究支持独立新报告与原文改写,并完善沙箱、模型管理与全文改写
新报告不再覆盖当前文件卡片,写入时打开沙箱;步骤条仅在改写原文时位于卡片上方。同时补齐改写本地回退、模型管理与会商第三步相关改动。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
11f928bc95
commit
a5a9c952e8
63 files changed
+4113
-929
No files matched your search
+3
-1
@@ -111,6 +111,7 @@ class DeepResearchSessionRepository:
|
||||
status: str | None = None,
|
||||
limit: int = 20,
|
||||
offset: int = 0,
|
||||
include_config: bool = False,
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Paginated session list for the history panel (excludes heavy report text)."""
|
||||
resolved = resolve_user_id(user_id, method_name="DeepResearchSessionRepository.list_by_user")
|
||||
@@ -128,7 +129,8 @@ class DeepResearchSessionRepository:
|
||||
d = self._row_to_dict(r)
|
||||
d.pop("report_markdown", None)
|
||||
d.pop("report_html", None)
|
||||
d.pop("config_snapshot", None)
|
||||
if not include_config:
|
||||
d.pop("config_snapshot", None)
|
||||
d.pop("plan_snapshot", None)
|
||||
d.pop("usage_snapshot", None)
|
||||
d.pop("error", None)
|
||||
|
||||
+61
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import uuid
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import func, select, update
|
||||
@@ -126,6 +127,66 @@ class DeepResearchSourceRepository:
|
||||
stmt = stmt.where(DeepResearchSourceRow.selected == selected)
|
||||
return int((await session.execute(stmt)).scalar() or 0)
|
||||
|
||||
async def clone_selected_to_session(
|
||||
self,
|
||||
source_session_id: str,
|
||||
target_session_id: str,
|
||||
*,
|
||||
user_id: str | _AutoSentinel = AUTO,
|
||||
) -> dict[str, str]:
|
||||
"""Copy the selected evidence into a new report session.
|
||||
|
||||
Source ids are globally unique primary keys, so a report variant cannot
|
||||
reuse the parent rows. Return the ``old_id -> new_id`` mapping to let
|
||||
the caller repair the copied Markdown citation markers before the
|
||||
variant becomes visible.
|
||||
"""
|
||||
resolved = resolve_user_id(
|
||||
user_id,
|
||||
method_name="DeepResearchSourceRepository.clone_selected_to_session",
|
||||
)
|
||||
async with self._sf() as session:
|
||||
stmt = select(DeepResearchSourceRow).where(
|
||||
DeepResearchSourceRow.session_id == source_session_id,
|
||||
DeepResearchSourceRow.selected.is_(True),
|
||||
)
|
||||
if resolved is not None:
|
||||
stmt = stmt.where(DeepResearchSourceRow.user_id == resolved)
|
||||
source_rows = (await session.execute(stmt)).scalars().all()
|
||||
|
||||
id_map: dict[str, str] = {}
|
||||
cloned_rows: list[DeepResearchSourceRow] = []
|
||||
for source in source_rows:
|
||||
cloned_id = f"drs_src_{uuid.uuid4().hex}"
|
||||
id_map[source.id] = cloned_id
|
||||
cloned_rows.append(
|
||||
DeepResearchSourceRow(
|
||||
id=cloned_id,
|
||||
session_id=target_session_id,
|
||||
job_id=None,
|
||||
user_id=resolved if resolved is not None else source.user_id,
|
||||
first_seen_query=source.first_seen_query,
|
||||
title=source.title,
|
||||
url=source.url,
|
||||
raw_content=source.raw_content,
|
||||
snippet=source.snippet,
|
||||
source=source.source,
|
||||
source_type=source.source_type,
|
||||
published_at=source.published_at,
|
||||
relevance_score=source.relevance_score,
|
||||
rec_uuid=source.rec_uuid,
|
||||
content_hash=source.content_hash,
|
||||
selected=True,
|
||||
selection_reason=source.selection_reason,
|
||||
citation_key=source.citation_key,
|
||||
)
|
||||
)
|
||||
if cloned_rows:
|
||||
session.add_all(cloned_rows)
|
||||
await session.flush()
|
||||
await session.commit()
|
||||
return id_map
|
||||
|
||||
# ── update selection ────────────────────────────────────────────────────
|
||||
|
||||
async def set_selected(
|
||||
|
||||
+10
-2
@@ -54,9 +54,17 @@ class DocumentRewriteVersionRepository:
|
||||
model_name=model_name,
|
||||
)
|
||||
session.add(row)
|
||||
# Do not refresh after commit. In a read/write-splitting MySQL
|
||||
# deployment that read can be routed to a lagging replica even
|
||||
# though the INSERT succeeded on the writer. The caller treats a
|
||||
# version-record failure as a reason to restore the document, so
|
||||
# that replica-only error would otherwise undo a valid rewrite.
|
||||
# Flush materializes the Python/SQLAlchemy defaults on the writer
|
||||
# and lets us return a complete snapshot without a second query.
|
||||
await session.flush()
|
||||
snapshot = self._row_to_dict(row)
|
||||
await session.commit()
|
||||
await session.refresh(row)
|
||||
return self._row_to_dict(row)
|
||||
return snapshot
|
||||
|
||||
async def get(
|
||||
self,
|
||||
|
||||
-3
@@ -46,7 +46,6 @@ from deerflow.persistence.deep_research_sessions.model import DeepResearchSessio
|
||||
from deerflow.persistence.deep_research_sources.model import DeepResearchSourceRow
|
||||
from deerflow.persistence.document_rewrite_versions.model import DocumentRewriteVersionRow
|
||||
from deerflow.persistence.embed_sessions.model import EmbedSessionRow
|
||||
from deerflow.persistence.enterprise_research.model import EnterpriseResearchReportJobRow, EnterpriseResearchTaskRow
|
||||
from deerflow.persistence.feedback.model import FeedbackRow
|
||||
from deerflow.persistence.intent_turns.model import IntentTurnRow
|
||||
from deerflow.persistence.light_apps.model import LightAppRow
|
||||
@@ -163,8 +162,6 @@ __all__ = [
|
||||
"TaskCopTaskRow",
|
||||
"TaskReportRow",
|
||||
"EmbedSessionRow",
|
||||
"EnterpriseResearchTaskRow",
|
||||
"EnterpriseResearchReportJobRow",
|
||||
"IntentTurnRow",
|
||||
"ThreadMetaRow",
|
||||
"ThreadShareRow",
|
||||
|
||||
Reference in new issue
Block a user