tail-fin-daemon 0.5.0

Long-running browser-session daemon for tail-fin (tfd binary). Keeps Chrome tabs warm across invocations via a Unix-socket protocol; registers Site implementations through a runtime Arc<dyn Site> registry.
Documentation
//! Command handlers. Each `sa.*`, `twitter.*`, `grok.*` cmd routes to a
//! function here that takes a `BrowserSession` and JSON params and returns
//! a JSON result.
//!
//! Site routing is by `Site::id()` rather than a closed enum, so adding a new
//! site with its own command namespace is a matter of:
//! 1. Implementing `tail_fin_core::Site` (usually in the site crate)
//! 2. Adding a handler module here with a `handle(...)` fn
//! 3. Adding one arm to the match below
//! 4. Registering the site via `tail_fin_daemon::driver::register_sites`

pub mod grok;
pub mod sa;
pub mod twitter;

use night_fury_core::BrowserSession;
use night_fury_daemon_core::protocol::Response;
use serde_json::Value;
use tail_fin_core::Site;

/// Route a cmd string to the appropriate handler. Returns `None` if the cmd
/// doesn't belong to `site` (so the caller can emit a clear error).
pub async fn dispatch(
    site: &dyn Site,
    session: &BrowserSession,
    id: &str,
    cmd: &str,
    params: &Value,
) -> Option<Response> {
    match site.id() {
        "sa" if cmd.starts_with("sa.") => Some(sa::handle(session, id, cmd, params).await),
        "twitter" if cmd.starts_with("twitter.") => {
            Some(twitter::handle(session, id, cmd, params).await)
        }
        "grok" if cmd.starts_with("grok.") => Some(grok::handle(session, id, cmd, params).await),
        _ => None,
    }
}