feat: AI writing history, Word export, roundtable dispatch chain
This commit is contained in:
1 parent
c0e3c5d692
commit
10334ddfe1
21 files changed
+1888
-143
No files matched your search
+67
@@ -0,0 +1,67 @@
|
||||
"""ORM model for roundtable background-orchestration jobs.
|
||||
|
||||
A "job" = one **backend** run of the roundtable orchestration pipeline kicked off
|
||||
from Step 2「后台挂起」: it drives the leader→dispatch→sub-agents loop to consensus
|
||||
and then Step 3 report drawing, entirely server-side, surviving page refresh/close.
|
||||
|
||||
Bound 1:1 to a ``roundtable_drafts`` row (``draft_id``) so the history dropdown can
|
||||
show "this task is running" and the dispatch-chain modal can render live progress.
|
||||
|
||||
Big JSON columns (``dispatch_chain`` / ``thread_ids`` / ``chain``) are stored as
|
||||
serialized strings in ``PortableLongText`` (MySQL ``LONGTEXT``) — same approach as
|
||||
``ai_writing_sessions`` / ``roundtable_drafts`` — to avoid MySQL's 64 KB ``TEXT`` cap.
|
||||
|
||||
See ``frontend-web/docs/multi-agent-background-run-dev.md`` §2.5 for the field
|
||||
contract and §Phase 1 for the build steps.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from sqlalchemy import Integer, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from deerflow.persistence.base import Base
|
||||
from deerflow.persistence.types import BeijingDateTime, PortableLongText
|
||||
|
||||
|
||||
class RoundtableJobRow(Base):
|
||||
__tablename__ = "roundtable_jobs"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
||||
# The draft/session this job runs for. Indexed for "active job of draft" lookups.
|
||||
draft_id: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
|
||||
user_id: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
|
||||
# Job status machine (§2.1): queued / running / awaiting_input / done / error / cancelled.
|
||||
status: Mapped[str] = mapped_column(String(32), nullable=False, default="queued", index=True)
|
||||
# Fine-grained phase (§2.2): initializing / leader_thinking / dispatching /
|
||||
# consensus / report_drawing / report_done.
|
||||
phase: Mapped[str] = mapped_column(String(32), nullable=False, default="initializing")
|
||||
# Current orchestration cycle (0..MAX_CYCLES).
|
||||
cycle: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
# Dispatch chain nodes (§2.3): JSON array of
|
||||
# { agentId, name, avatarType, order, state, lastSpokeCycle? }.
|
||||
dispatch_chain: Mapped[str | None] = mapped_column(PortableLongText, nullable=True)
|
||||
# Currently-speaking seat agent_id (null = coordinator / none).
|
||||
active_agent_id: Mapped[str | None] = mapped_column(String(128), nullable=True)
|
||||
consensus_percentage: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
# When status=awaiting_input: the coordinator's clarification question text.
|
||||
pending_clarification: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
# ThreadIdMap: JSON object { "<agent_id>": "<thread_id>", ... }.
|
||||
thread_ids: Mapped[str | None] = mapped_column(PortableLongText, nullable=True)
|
||||
coordinator_name: Mapped[str | None] = mapped_column(String(128), nullable=True)
|
||||
# "recommend"(总控自由派活)| "chain"(按业务链条顺序派活).
|
||||
orchestration_mode: Mapped[str] = mapped_column(String(16), nullable=False, default="recommend")
|
||||
# chain 模式来源链条快照:JSON object { id, title }(recommend 模式为 null).
|
||||
chain: Mapped[str | None] = mapped_column(PortableLongText, nullable=True)
|
||||
# Terminal error detail when status=error.
|
||||
error: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
# 时间列必须用 BeijingDateTime(项目规范,与 ai_writing_sessions / roundtable_drafts 对齐)。
|
||||
created_at: Mapped[datetime] = mapped_column(BeijingDateTime(), nullable=False, default=lambda: datetime.now(UTC))
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
BeijingDateTime(),
|
||||
nullable=False,
|
||||
default=lambda: datetime.now(UTC),
|
||||
onupdate=lambda: datetime.now(UTC),
|
||||
)
|
||||
Reference in new issue
Block a user