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

@@ -87,6 +87,32 @@ class MafToolMetadata(BaseModel):
return namespace
class MafBusinessRoute(BaseModel):
"""Server-owned route for one MAF business chain.
The browser and the model never submit these agent ids. Operators must
configure the exact ids discovered in the deployment's agent catalog.
Keeping the route in the MAF config also makes a session reproducible: the
selected route is frozen into its trusted capability snapshot at launch.
"""
manager_agent_id: str = Field(min_length=1, max_length=64)
seat_agent_ids: list[str] = Field(default_factory=list, max_length=64)
mode: MafMode | None = None
@field_validator("seat_agent_ids")
@classmethod
def _validate_seat_agent_ids(cls, ids: list[str]) -> list[str]:
normalized: list[str] = []
for agent_id in ids:
value = str(agent_id).strip()
if not value or len(value) > 64:
raise ValueError("seat_agent_ids must contain non-empty agent ids")
if value not in normalized:
normalized.append(value)
return normalized
class MafRoundtableConfig(BaseModel):
"""Microsoft Agent Framework 多智能体会商实验功能开关。
@@ -116,6 +142,13 @@ class MafRoundtableConfig(BaseModel):
le=64,
description="默认最大轮次上限(群聊模式硬上限,避免弱模型无限讨论)",
)
# Stage 3: server-owned routing. These remain empty in the repository;
# production deployments must inject exact agent ids in their deployment
# configuration instead of guessing from names or client input.
default_manager_agent_id: str | None = Field(default=None, max_length=64)
default_seat_agent_ids: list[str] = Field(default_factory=list, max_length=64)
business_routes: dict[str, MafBusinessRoute] = Field(default_factory=dict)
max_seats_per_run: int = Field(default=16, ge=1, le=64)
# 管理员诊断是否可见所有用户的会商(true=管理员跨用户读,false=管理员也只能看自己的)。
admin_diagnostic_access: bool = Field(
default=True,
@@ -162,6 +195,7 @@ class MafRoundtableConfig(BaseModel):
__all__ = [
"MafMode",
"MafBusinessRoute",
"MafParticipantRole",
"MafRiskLevel",
"MafRoundtableConfig",