use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use crate::session::SessionId;
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum Content {
Text {
text: String,
},
Image {
data: String,
mime_type: String,
},
}
impl Content {
pub fn text(s: impl Into<String>) -> Self {
Content::Text { text: s.into() }
}
pub fn image(data: impl Into<String>, mime_type: impl Into<String>) -> Self {
Content::Image {
data: data.into(),
mime_type: mime_type.into(),
}
}
}
impl From<Content> for Vec<Content> {
fn from(c: Content) -> Self {
vec![c]
}
}
pub fn content_text(contents: &[Content]) -> String {
contents
.iter()
.filter_map(|c| match c {
Content::Text { text } => Some(text.as_str()),
Content::Image { .. } => None,
})
.collect::<Vec<_>>()
.join("\n")
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ToolMetadata {
pub name: String,
pub description: String,
pub origin: String,
pub version: String,
pub requirements: Vec<String>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ToolExposure {
Direct,
Deferred,
Hidden,
}
#[derive(Clone, Debug)]
pub struct ActivationContext {
pub session_id: SessionId,
pub current_tools: Vec<String>,
pub workspace: PathBuf,
}