chore: add WebSocket API with Mongoose, service management, and AI command execution

Add new WebSocket API module (api.c/api.h) using Mongoose library for real-time
window manager control, including workspace and client status endpoints.
Introduce service management module (services.h) with init/run/cleanup lifecycle.
Extend AI module to parse [WM_CMD:] directives from responses and forward JSON
commands to the API handler. Update config with api.enabled, api.port, and
services.path settings. Integrate new modules into main init/run/cleanup flow.
This commit is contained in:
2026-01-08 22:58:19 +00:00
parent 54565b21bd
commit 4793d372ac
16 changed files with 20963 additions and 6 deletions
+22
View File
@@ -85,6 +85,14 @@ void config_set_defaults(Config *cfg)
dwn_free(autostart_path);
}
char *services_path = expand_path("~/.config/dwn/services.d");
if (services_path != NULL) {
strncpy(cfg->services_path, services_path, sizeof(cfg->services_path) - 1);
dwn_free(services_path);
}
cfg->api_enabled = true;
cfg->api_port = 8777;
cfg->demo_step_delay_ms = 4000;
cfg->demo_ai_timeout_ms = 15000;
cfg->demo_window_timeout_ms = 5000;
@@ -180,6 +188,20 @@ static void handle_config_entry(const char *section, const char *key,
dwn_free(expanded);
}
}
} else if (strcmp(section, "services") == 0) {
if (strcmp(key, "path") == 0) {
char *expanded = expand_path(value);
if (expanded != NULL) {
strncpy(cfg->services_path, expanded, sizeof(cfg->services_path) - 1);
dwn_free(expanded);
}
}
} else if (strcmp(section, "api") == 0) {
if (strcmp(key, "enabled") == 0) {
cfg->api_enabled = (strcmp(value, "true") == 0 || strcmp(value, "1") == 0);
} else if (strcmp(key, "port") == 0) {
cfg->api_port = atoi(value);
}
} else if (strcmp(section, "demo") == 0) {
if (strcmp(key, "step_delay") == 0) {
int val = atoi(value);