use std::sync::Arc;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use crate::error::Result;
use crate::id::SessionId;
use crate::tool::{Tool, ToolOutput};
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct SystemPromptContext {
pub session_id: SessionId,
}
impl SystemPromptContext {
pub fn new(session_id: SessionId) -> Self {
Self { session_id }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CommandDescriptor {
pub name: String,
pub description: String,
}
impl CommandDescriptor {
pub fn new(name: impl Into<String>, description: impl Into<String>) -> Self {
Self {
name: name.into(),
description: description.into(),
}
}
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct CommandContext {
pub session_id: SessionId,
}
impl CommandContext {
pub fn new(session_id: SessionId) -> Self {
Self { session_id }
}
}
#[async_trait]
pub trait Capability: Send + Sync {
fn id(&self) -> &str;
fn name(&self) -> &str {
self.id()
}
fn description(&self) -> &str {
""
}
fn metadata(&self) -> serde_json::Value {
serde_json::Value::Null
}
async fn system_prompt_contribution(&self, _context: &SystemPromptContext) -> Option<String> {
None
}
async fn tools(&self) -> Result<Vec<Arc<dyn Tool>>> {
Ok(Vec::new())
}
fn commands(&self) -> Vec<CommandDescriptor> {
Vec::new()
}
async fn execute_command(
&self,
_name: &str,
_args: &str,
_context: &CommandContext,
) -> Option<ToolOutput> {
None
}
}