feat: 深度研究支持独立新报告与原文改写,并完善沙箱、模型管理与全文改写

新报告不再覆盖当前文件卡片,写入时打开沙箱;步骤条仅在改写原文时位于卡片上方。同时补齐改写本地回退、模型管理与会商第三步相关改动。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
董宏凯andCursor committed 2026-08-21 21:46:04 +08:00
1 parent 11f928bc95
commit a5a9c952e8
63 files changed
+4113 -929

No files matched your search

@@ -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(