feat(ipc): add request_confirmation to ApiHookClient
This commit is contained in:
@@ -21,13 +21,13 @@ class ApiHookClient:
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _make_request(self, method, endpoint, data=None):
|
def _make_request(self, method, endpoint, data=None, timeout=None):
|
||||||
url = f"{self.base_url}{endpoint}"
|
url = f"{self.base_url}{endpoint}"
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
|
|
||||||
last_exception = None
|
last_exception = None
|
||||||
# Lower request timeout for local server
|
# Lower request timeout for local server by default
|
||||||
req_timeout = 0.5
|
req_timeout = timeout if timeout is not None else 0.5
|
||||||
|
|
||||||
for attempt in range(self.max_retries + 1):
|
for attempt in range(self.max_retries + 1):
|
||||||
try:
|
try:
|
||||||
@@ -207,3 +207,11 @@ class ApiHookClient:
|
|||||||
def reset_session(self):
|
def reset_session(self):
|
||||||
"""Simulates clicking the 'Reset Session' button in the GUI."""
|
"""Simulates clicking the 'Reset Session' button in the GUI."""
|
||||||
return self.click("btn_reset")
|
return self.click("btn_reset")
|
||||||
|
|
||||||
|
def request_confirmation(self, tool_name, args):
|
||||||
|
"""Asks the user for confirmation via the GUI (blocking call)."""
|
||||||
|
# Using a long timeout as this waits for human input (60 seconds)
|
||||||
|
res = self._make_request('POST', '/api/ask',
|
||||||
|
data={'type': 'tool_approval', 'tool': tool_name, 'args': args},
|
||||||
|
timeout=60.0)
|
||||||
|
return res.get('response')
|
||||||
|
|||||||
Reference in New Issue
Block a user