Skip to content

chart

Chart planner + chart cache.

Self-contained chart subsystem with two layers:

  1. Inner planner agent (private). Pure dataset-in / EChartsOption-out brain. Driven by prepareChart; callers never instantiate it directly.
  2. prepareChart: orchestration on top of the planner. Mints a chartId, caches an empty { chartId } record synchronously, then resolves the dataset and runs the planner in the background. The terminal entry settles with either result (success) or error (failure). Both undefined means the entry is still processing.

The cache surface (fetchChart) is the only state the HTTP route and the chart-producing tools share. prepareChart is dataset-agnostic - callers supply a resolveData callback that fetches the rows however they like (Genie statement, inline dataset, custom API). The module has no knowledge of Genie or statement ids; those concerns live in the tools that wrap it.

Wire-format schemas live in @dbx-tools/shared-mastra so the demo client and any other UI consumer share the exact same shape this module reads and writes.