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:
Devid HW
2026-04-19 01:56:41 +07:00
parent 13e821bc5d
commit e94ec8153d
6 changed files with 159 additions and 0 deletions
+1
View File
@@ -27,3 +27,4 @@ encoding_rs = "0.8"
tempfile = "3.0"
roxmltree = "0.21.1"
rusqlite = { version = "0.31", features = ["bundled"] }
base64 = "0.22"