never ends
This commit is contained in:
@@ -15,10 +15,8 @@ class ApiHookClient:
|
||||
headers = {}
|
||||
if self.api_key:
|
||||
headers["X-API-KEY"] = self.api_key
|
||||
|
||||
if method not in ('GET', 'POST', 'DELETE'):
|
||||
raise ValueError(f"Unsupported HTTP method: {method}")
|
||||
|
||||
try:
|
||||
if method == 'GET':
|
||||
response = requests.get(url, headers=headers, timeout=timeout)
|
||||
@@ -26,12 +24,11 @@ class ApiHookClient:
|
||||
response = requests.post(url, json=data, headers=headers, timeout=timeout)
|
||||
elif method == 'DELETE':
|
||||
response = requests.delete(url, headers=headers, timeout=timeout)
|
||||
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
return None
|
||||
except Exception as e:
|
||||
# Silently ignore connection errors unless we are in a wait loop
|
||||
# Silently ignore connection errors unless we are in a wait loop
|
||||
return None
|
||||
|
||||
def wait_for_server(self, timeout: int = 15) -> bool:
|
||||
@@ -48,15 +45,14 @@ class ApiHookClient:
|
||||
"""Checks the health of the hook server."""
|
||||
res = self._make_request('GET', '/status')
|
||||
if res is None:
|
||||
# For backward compatibility with tests expecting ConnectionError
|
||||
# But our _make_request handles it. Let's return empty if failed.
|
||||
# For backward compatibility with tests expecting ConnectionError
|
||||
# But our _make_request handles it. Let's return empty if failed.
|
||||
return {}
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def post_project(self, project_data: dict) -> dict[str, Any]:
|
||||
return self._make_request('POST', '/api/project', data=project_data) or {}
|
||||
|
||||
def get_project(self) -> dict[str, Any]:
|
||||
"""Retrieves the current project state."""
|
||||
return self._make_request('GET', '/api/project') or {}
|
||||
@@ -69,7 +65,6 @@ class ApiHookClient:
|
||||
"""Updates the session history."""
|
||||
return self._make_request('POST', '/api/session', data={"session": {"entries": session_entries}}) or {}
|
||||
|
||||
|
||||
def get_events(self) -> list[dict[str, Any]]:
|
||||
res = self._make_request('GET', '/api/events')
|
||||
return res.get("events", []) if res else []
|
||||
@@ -111,13 +106,11 @@ class ApiHookClient:
|
||||
state = self.get_gui_state()
|
||||
if item in state:
|
||||
return state[item]
|
||||
|
||||
# Fallback for thinking/live/prior which are in diagnostics
|
||||
# Fallback for thinking/live/prior which are in diagnostics
|
||||
diag = self.get_gui_diagnostics()
|
||||
if diag and item in diag:
|
||||
return diag[item]
|
||||
|
||||
# Map common indicator tags to diagnostics keys
|
||||
# Map common indicator tags to diagnostics keys
|
||||
mapping = {
|
||||
"thinking_indicator": "thinking",
|
||||
"operations_live_indicator": "live",
|
||||
@@ -126,7 +119,6 @@ class ApiHookClient:
|
||||
key = mapping.get(item)
|
||||
if diag and key and key in diag:
|
||||
return diag[key]
|
||||
|
||||
return None
|
||||
|
||||
def get_text_value(self, item_tag: str) -> str | None:
|
||||
|
||||
Reference in New Issue
Block a user