a3s-code-core 2.5.0

A3S Code Core - Embeddable AI agent library with tool execution
Documentation
//! Host-facing slash command registry control.
//!
//! Slash commands are part of the session control plane: hosts can inspect and
//! extend the registry, while conversation runtime dispatches commands before
//! calling the LLM. This module keeps registry locking and dispatch locality in
//! one place.

use super::AgentSession;
use crate::commands::{CommandContext, CommandOutput, CommandRegistry, SlashCommand};
use std::sync::{Arc, MutexGuard};

pub(super) fn registry(session: &AgentSession) -> MutexGuard<'_, CommandRegistry> {
    session
        .command_registry
        .lock()
        .expect("command_registry lock poisoned")
}

pub(super) fn register(session: &AgentSession, cmd: Arc<dyn SlashCommand>) {
    registry(session).register(cmd);
}

pub(super) fn dispatch(
    session: &AgentSession,
    prompt: &str,
    ctx: &CommandContext,
) -> Option<CommandOutput> {
    registry(session).dispatch(prompt, ctx)
}