generated from coulomb/repo-seed
feat(statehub): add offline write buffer relay
This commit is contained in:
@@ -82,6 +82,13 @@ succeeds but its automatic progress event fails, the tool returns an error with
|
||||
the successful `write_result` included so the caller can avoid duplicating the
|
||||
entity while recording the missing progress event.
|
||||
|
||||
When API_BASE points at the optional State Hub edge relay and the central API is
|
||||
unreachable, queueable write tools may return a queued receipt instead of the
|
||||
normal REST shape. The receipt means the local outbox accepted the write; it is
|
||||
not yet a central commit. Automatic progress-event side effects are skipped for
|
||||
queued primary writes so replay does not duplicate records. Operators can inspect
|
||||
and replay with statehub outbox status and statehub outbox replay.
|
||||
|
||||
---
|
||||
|
||||
## Query Tools (read-only, use freely)
|
||||
|
||||
@@ -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