feat(maf): conversation-driven MAF roundtable (R1/R2) + server-owned stage-3 dispatch

Backend:
- Conversation API at /api/maf-roundtable/conversations: create/list/detail,
  paginated messages, atomic send+run start, owner-only isolation,
  admin read-only diagnostic access
- SSE real-time event stream (GET /conversations/{id}/stream) backed by
  ConversationEventHub + conversation_events store; multi-worker deployment doc
- Deterministic server-owned stage-3 dispatch contracts (dispatch_contracts.py):
  routing resolved from trusted MAF deployment config instead of manager-chosen
  agent ids; config.yaml keeps stage-3 routing deployment-owned
  (default_manager_agent_id / seat ids / business_routes / max_seats_per_run)
- Conversation persistence (conversations/messages stores) + v2 migration script
- Tests: conversations, conversation stream, migration, phase3 conversation dispatch

Frontend:
- Vitest test infra for MAF (vitest.maf.config.ts + test:maf script) with
  component tests for ApprovalCard/RunHeader/SessionsPage and use-maf-events
- Session form lib, flow-graph dialog / run-detail / sessions page updates,
  routes and nav tweaks
- Docs: R0 legacy interaction baseline mapping, updated implementation plan

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
董宏凯andCursor committed 2026-08-03 12:09:47 +08:00
1 parent df408831e5
commit 99642fca6c
46 files changed
+6358 -1306

No files matched your search

@@ -488,6 +488,7 @@ class DeerFlowAgentAdapter:
raise AuditEventError(
f"Critical audit event '{event.get('event_type')}' failed to persist: {exc}"
) from exc
await self._bridge_conversation_event(run_id, event)
async def _emit(self, run_id: str, event: dict[str, Any]) -> None:
"""Emit a non-critical event (agent.message.delta). Failure degrades gracefully.
@@ -518,6 +519,42 @@ class DeerFlowAgentAdapter:
)
except Exception:
logger.warning("non-critical event %s failed for run %s (degraded)", event_type, run_id, exc_info=True)
return
await self._bridge_conversation_event(run_id, event)
async def _bridge_conversation_event(self, run_id: str, event: dict[str, Any]) -> None:
"""Best-effort projection into the V2 conversation event stream.
The per-run audit write above remains authoritative. A projection
failure must not cause a tool to execute twice or turn a completed
seat run into a false runtime failure; reconnect/recovery can rebuild
the conversation view from the audit ledger later.
P0-3: the entire ``app.state`` resolution is best-effort. If any link
is missing (no app, no state, no conversation service), the projection
is silently skipped — audit, recovery, cancel, lease, and tool
execution safety are never affected.
"""
try:
app = getattr(self._client, "app", None)
state = getattr(app, "state", None)
conversation_service = getattr(state, "maf_conversation_service", None)
except Exception: # noqa: BLE001
return
if conversation_service is None:
return
bridge = getattr(conversation_service, "bridge_workflow_event", None)
if not callable(bridge):
return
try:
await bridge(run_id=run_id, event=event)
except Exception: # noqa: BLE001 - audit already persisted
logger.warning(
"conversation event projection failed for run %s (%s)",
run_id,
event.get("event_type"),
exc_info=True,
)
# ── internal helpers ────────────────────────────────────────────────────