generated from coulomb/repo-seed
Task flow engine implementation
This commit is contained in:
@@ -173,7 +173,11 @@ def get_domain_summary(domain_slug: str) -> str:
|
||||
|
||||
topic_id = topic["id"]
|
||||
|
||||
workstreams = _get("/workstreams", {"topic_id": topic_id, "status": "active"})
|
||||
state_summary = _get("/state/summary")
|
||||
workstreams = [
|
||||
ws for ws in state_summary.get("open_workstreams", [])
|
||||
if ws.get("topic_id") == topic_id
|
||||
]
|
||||
blocking = _get("/decisions", {"decision_type": "pending", "topic_id": topic_id})
|
||||
recent = _get("/progress", {"topic_id": topic_id, "limit": 5})
|
||||
repos = _get("/repos", {"domain": domain_slug})
|
||||
@@ -348,6 +352,60 @@ def get_recent_progress(limit: int = 20, since: str | None = None) -> str:
|
||||
return json.dumps(_get("/progress", {"limit": limit, "since": since}), indent=2)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def list_flow_definitions() -> str:
|
||||
"""List registered declarative flow definitions.
|
||||
|
||||
Returns each entity type, its workstations, and entry/exit assertion counts.
|
||||
Use this for orientation before calling get_flow_state or advance_workstation.
|
||||
"""
|
||||
return json.dumps(_get("/flows/definitions"), indent=2)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def get_flow_state(entity_type: str, entity_id: str) -> str:
|
||||
"""Return the declarative flow state for one entity.
|
||||
|
||||
Args:
|
||||
entity_type: workstream | task | contribution | capability_request
|
||||
entity_id: UUID of the entity
|
||||
|
||||
Returns current workstation, exit-blocking assertions, reachable
|
||||
workstations, and unreachable workstations with the first blocking
|
||||
assertion for each.
|
||||
"""
|
||||
return json.dumps(_get(f"/flows/{entity_type}/{entity_id}"), indent=2)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def advance_workstation(entity_type: str, entity_id: str, target_workstation: str) -> str:
|
||||
"""Attempt to move an entity to a target workstation.
|
||||
|
||||
Args:
|
||||
entity_type: workstream | task | contribution | capability_request
|
||||
entity_id: UUID of the entity
|
||||
target_workstation: desired workstation/status name
|
||||
|
||||
Returns the new FlowResult on success. If the target is unreachable, the
|
||||
response contains a 409-equivalent error with machine-readable failing
|
||||
assertions.
|
||||
"""
|
||||
result = _post(f"/flows/{entity_type}/{entity_id}/advance/{target_workstation}", {})
|
||||
if not isinstance(result, dict) or "error" not in result:
|
||||
_post("/progress", {
|
||||
"event_type": "workstation_advanced",
|
||||
"summary": f"{entity_type} {entity_id} advanced to {target_workstation}",
|
||||
"author": "custodian",
|
||||
"detail": {
|
||||
"entity_type": entity_type,
|
||||
"entity_id": entity_id,
|
||||
"target_workstation": target_workstation,
|
||||
"flow_result": result,
|
||||
},
|
||||
})
|
||||
return json.dumps(result, indent=2)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Mutate tools
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user