Skip to main content

cersei_tools/
synthetic_output.rs

1//! SyntheticOutput tool: return structured JSON data for SDK/coordinator sessions.
2
3use super::*;
4
5pub struct SyntheticOutputTool;
6
7#[async_trait]
8impl Tool for SyntheticOutputTool {
9    fn name(&self) -> &str {
10        "SyntheticOutput"
11    }
12    fn description(&self) -> &str {
13        "Return structured JSON output for programmatic consumption. Used by coordinator mode and SDK integrations."
14    }
15    fn permission_level(&self) -> PermissionLevel {
16        PermissionLevel::None
17    }
18
19    fn input_schema(&self) -> Value {
20        serde_json::json!({
21            "type": "object",
22            "properties": {
23                "data": {
24                    "description": "Structured data to return (any valid JSON)"
25                }
26            },
27            "required": ["data"]
28        })
29    }
30
31    async fn execute(&self, input: Value, _ctx: &ToolContext) -> ToolResult {
32        let data = input.get("data").cloned().unwrap_or(Value::Null);
33        ToolResult::success(serde_json::to_string_pretty(&data).unwrap_or_default())
34            .with_metadata(serde_json::json!({"type": "synthetic_output", "data": data}))
35    }
36}