Add get_latest_report tool with equity chart support
**New Tool: get_latest_report** - Returns the most recent backtest report from the database - Includes full report details: metrics, paths, tags, notes, verdict - Optional include_chart parameter (default: true) - Returns equity chart as base64 PNG when available **Implementation:** - ReportDb.get_latest(): Query for most recent report by created_at DESC - handle_get_latest_report(): Fetches report and reads equity.png from charts_dir - Base64 encoding using base64 crate v0.22 - Graceful handling when chart not found (equity_chart_error field) **Files Changed:** - storage/database.rs: Added get_latest() method - tools/definitions.rs: Added tool_get_latest_report() definition - tools/handlers/mod.rs: Added dispatch for get_latest_report - tools/handlers/reports.rs: Implemented handler with base64 chart encoding - Cargo.toml: Added base64 = 0.22 dependency
This commit is contained in:
@@ -16,6 +16,7 @@ pub fn get_tools_list() -> Value {
|
||||
tool_get_backtest_status(),
|
||||
tool_get_optimization_status(),
|
||||
tool_prune_reports(),
|
||||
tool_get_latest_report(),
|
||||
tool_list_reports(),
|
||||
tool_search_reports(),
|
||||
tool_tail_log(),
|
||||
@@ -256,6 +257,19 @@ fn tool_prune_reports() -> Value {
|
||||
})
|
||||
}
|
||||
|
||||
fn tool_get_latest_report() -> Value {
|
||||
json!({
|
||||
"name": "get_latest_report",
|
||||
"description": "Get the latest backtest report with full details and equity chart image",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"include_chart": { "type": "boolean", "description": "Include equity chart as base64 PNG (default: true)", "default": true }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn tool_list_reports() -> Value {
|
||||
json!({
|
||||
"name": "list_reports",
|
||||
|
||||
Reference in New Issue
Block a user