generated from coulomb/repo-seed
feat(statehub): add offline write buffer relay
This commit is contained in:
@@ -120,12 +120,23 @@ def _mcp_error(tool_name: str, message: str, response: Any | None = None) -> dic
|
||||
return payload
|
||||
|
||||
|
||||
|
||||
def _mcp_queued(tool_name: str, response: dict[str, Any]) -> dict[str, Any]:
|
||||
return {
|
||||
"queued": True,
|
||||
"tool": tool_name,
|
||||
"message": "Write queued by State Hub edge relay; central commit is pending replay.",
|
||||
"receipt": response,
|
||||
}
|
||||
|
||||
def _response_error(
|
||||
tool_name: str,
|
||||
response: Any,
|
||||
required_fields: tuple[str, ...] = (),
|
||||
) -> dict[str, Any] | None:
|
||||
"""Return an MCP-visible error payload for failed or malformed API results."""
|
||||
if isinstance(response, dict) and response.get("queued") is True:
|
||||
return _mcp_queued(tool_name, response)
|
||||
if isinstance(response, dict) and isinstance(response.get("error"), str):
|
||||
return _mcp_error(tool_name, response["error"], response)
|
||||
if not isinstance(response, dict):
|
||||
|
||||
Reference in New Issue
Block a user