huskies: merge 858

This commit is contained in:
dave
2026-04-29 10:41:32 +00:00
parent be5db846cc
commit 11d111360d
79 changed files with 265 additions and 0 deletions
+25
View File
@@ -1,26 +1,46 @@
//! HTTP server — module declarations for all REST, MCP, WebSocket, and SSE endpoints.
/// Agent management HTTP endpoints.
pub mod agents;
/// Server-sent event stream for real-time agent output.
pub mod agents_sse;
/// Anthropic API key management endpoints.
pub mod anthropic;
/// Static asset serving (embedded frontend files).
pub mod assets;
/// Bot slash-command HTTP endpoint.
pub mod bot_command;
/// Bot configuration read/write endpoints.
pub mod bot_config;
/// Chat session HTTP endpoints.
pub mod chat;
/// Shared application context threaded through handlers.
pub mod context;
/// Server-sent event stream for pipeline/watcher events.
pub mod events;
/// Node identity endpoint (public key, node ID).
pub mod identity;
/// Filesystem I/O HTTP endpoints (read, write, list, search).
pub mod io;
/// Model Context Protocol (MCP) HTTP endpoint and tool modules.
pub mod mcp;
/// LLM model selection and listing endpoints.
pub mod model;
/// OAuth 2.0 PKCE flow endpoints for Anthropic authentication.
pub mod oauth;
/// Project settings HTTP endpoints.
pub mod settings;
#[cfg(test)]
pub(crate) mod test_helpers;
/// Workflow helpers for story/bug file operations.
pub mod workflow;
/// Gateway-mode HTTP endpoints for multi-project proxy.
pub mod gateway;
/// Project open/close/list HTTP endpoints.
pub mod project;
/// Setup wizard HTTP endpoints.
pub mod wizard;
/// WebSocket handler for real-time frontend communication.
pub mod ws;
use agents::AgentsApi;
@@ -44,26 +64,31 @@ use crate::chat::transport::whatsapp::WhatsAppWebhookContext;
const DEFAULT_PORT: u16 = 3001;
/// Parse an optional port string, falling back to the default (3001).
pub fn parse_port(value: Option<String>) -> u16 {
value
.and_then(|v| v.parse::<u16>().ok())
.unwrap_or(DEFAULT_PORT)
}
/// Read the server port from the `HUSKIES_PORT` env var, or use the default.
pub fn resolve_port() -> u16 {
parse_port(std::env::var("HUSKIES_PORT").ok())
}
/// Write a `.huskies_port` file so other processes can discover the port.
pub fn write_port_file(dir: &Path, port: u16) -> Option<PathBuf> {
let path = dir.join(".huskies_port");
std::fs::write(&path, port.to_string()).ok()?;
Some(path)
}
/// Delete the `.huskies_port` file on shutdown.
pub fn remove_port_file(path: &Path) {
let _ = std::fs::remove_file(path);
}
/// Assemble the full Poem route tree (API, WebSocket, MCP, OAuth, assets).
pub fn build_routes(
ctx: AppContext,
whatsapp_ctx: Option<Arc<WhatsAppWebhookContext>>,