feat(api): Add lightweight HTTP server for API hooks

This commit is contained in:
2026-02-23 12:11:01 -05:00
parent bd7ccf3a07
commit 44c2585f95
3 changed files with 68 additions and 0 deletions

5
gui.py
View File

@@ -25,6 +25,7 @@ import shell_runner
import session_logger
import project_manager
import theme
import api_hooks
CONFIG_PATH = Path("config.toml")
PROVIDERS = ["gemini", "anthropic"]
@@ -396,6 +397,7 @@ class App:
def __init__(self):
self.config = load_config()
self.test_hooks_enabled = '--enable-test-hooks' in sys.argv or os.environ.get('SLOP_TEST_HOOKS') == '1'
self.hook_server = api_hooks.HookServer(self)
# ---- global settings from config.toml ----
ai_cfg = self.config.get("ai", {})
@@ -2057,6 +2059,8 @@ class App:
self._rebuild_projects_list()
self._rebuild_discussion_selector()
self._fetch_models(self.current_provider)
self.hook_server.start()
while dpg.is_dearpygui_running():
# Show any pending confirmation dialog on the main thread safely
@@ -2184,6 +2188,7 @@ class App:
dpg.save_init_file("dpg_layout.ini")
session_logger.close_session()
ai_client.cleanup() # Destroy active API caches to stop billing
self.hook_server.stop()
dpg.destroy_context()