use schemars::JsonSchema;
use serde::Serialize;
use exocortex_ops::{OpContext, OpError};
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct PlaybookVersionOutput {
pub version: String,
pub playbook_hash: String,
pub block_hash: String,
}
async fn playbook_version_handle(
_ctx: &OpContext,
_input: serde_json::Value,
) -> Result<PlaybookVersionOutput, OpError> {
Ok(PlaybookVersionOutput {
version: crate::playbook::PLAYBOOK_VERSION.into(),
playbook_hash: crate::playbook::playbook_hash(),
block_hash: crate::playbook::block_hash(),
})
}
inventory::submit! {
exocortex_ops::OperationEntry {
name: "playbook_version",
mcp_tool_name: "exocortex.playbook_version",
pack: None,
http_method: || http::Method::POST,
http_path: "/v1/playbook_version",
input_schema: || schemars::schema_for!(serde_json::Value),
output_schema: || schemars::schema_for!(PlaybookVersionOutput),
handler: |_entry, ctx, v| Box::pin(async move {
let out = playbook_version_handle(ctx, v).await?;
serde_json::to_value(out).map_err(|e| OpError::Other(e.to_string()))
}),
}
}