use async_trait::async_trait;
use car_engine::ToolExecutor;
use serde_json::{json, Value};
pub const TOOL_CAPABILITIES: &str = "parslee_capabilities";
pub const TOOL_GENERATE_DOCUMENT: &str = "parslee_m365_generate_document";
pub struct ParsleeToolExecutor;
impl ParsleeToolExecutor {
pub fn tool_defs() -> Vec<Value> {
vec![
json!({
"name": TOOL_CAPABILITIES,
"description": "Discover what the signed-in Parslee account can do: \
identity, enabled product entitlements (studio, aie, odi, …), and \
Studio reachability. Read-only. Call this first to learn which \
products are available before using a product tool.",
"parameters": { "type": "object", "properties": {} }
}),
json!({
"name": TOOL_GENERATE_DOCUMENT,
"description": "Generate a Word document from a natural-language brief and \
save it to the user's connected drive (OneDrive/Google Drive). Requires \
the 'aie' entitlement. Returns the saved file's id and web URL.",
"parameters": {
"type": "object",
"properties": {
"content_brief": {
"type": "string",
"description": "What the document should contain (20–2000 characters)."
},
"output_file_path": {
"type": "string",
"description": "Path in the user's drive, e.g. \"Generated/report.docx\"."
},
"document_type": {
"type": "string",
"description": "Report|Proposal|Memo|Letter|Contract|ExecutiveSummary|MeetingMinutes|ProjectPlan (default Report)."
},
"title": { "type": "string", "description": "Optional title override." },
"author": { "type": "string", "description": "Optional author name." }
},
"required": ["content_brief", "output_file_path"]
}
}),
]
}
pub fn tool_names() -> Vec<String> {
vec![
TOOL_CAPABILITIES.to_string(),
TOOL_GENERATE_DOCUMENT.to_string(),
]
}
}
#[async_trait]
impl ToolExecutor for ParsleeToolExecutor {
async fn execute(&self, tool: &str, params: &Value) -> Result<Value, String> {
match tool {
TOOL_CAPABILITIES => crate::parslee_capabilities::discover().await,
TOOL_GENERATE_DOCUMENT => crate::parslee_m365::generate_document(params).await,
other => Err(format!("unknown Parslee tool: {other}")),
}
}
}