Add State Hub RecentlyOnScope invocation

This commit is contained in:
2026-05-22 16:14:10 +02:00
parent f4c38e2d5f
commit 5055f3eaca
4 changed files with 73 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ Supported queries:
- workplan_index: GET {STATE_HUB_URL}/workstreams/workplan-index
- hub_inbox: GET {STATE_HUB_URL}/messages/?to_agent=hub&unread_only=true
- daily_triage_digest: curated scalar JSON digest for daily WSJF triage
- recently_on_scope_hourly: POST {STATE_HUB_URL}/recently-on-scope/hourly
No caching — state hub data is live operational state and must not be stale
within a single workflow run.
@@ -45,6 +46,13 @@ def _fetch_json(path: str, params: dict[str, Any] | None = None) -> Any:
return {}
def _post_json(path: str, payload: dict[str, Any]) -> Any:
url = f"{_base_url()}{path}"
resp = httpx.post(url, json=payload, timeout=_TIMEOUT_SECONDS)
resp.raise_for_status()
return resp.json()
class StateHubContextResolver(ContextResolver):
"""Fetches live data from the Custodian State Hub."""
@@ -70,6 +78,13 @@ class StateHubContextResolver(ContextResolver):
return _fetch_json("/messages/", query_params)
if query == "daily_triage_digest":
return _daily_triage_digest(params)
if query == "recently_on_scope_hourly":
payload = {
key: value
for key, value in params.items()
if key not in {"required"}
}
return _post_json("/recently-on-scope/hourly", payload)
return {}