# Reports

The 4 tools for reports. Before an agent first makes one, it reads guide topic reports.

## create_report

Make a report: a document people read and share — a briefing, an explainer, a research write-up, a product spec, a proposal, an investor update, a quarterly or campaign review. It is one HTML page on Artifacts' standard report look: theme.css (added for you; link it with <link rel="stylesheet" href="theme.css">) gives the title and meta line, headline numbers, figures for charts and diagrams, cards, panels, tables and the rest, as a kit you compose freely: any arrangement of pictures, charts, numbers, cards and text the content needs, with your own HTML and CSS (on its tokens) for what the kit lacks. theme picks its fonts and colors. A written report cites what it relies on in the page; a report that shows the space's numbers names them in sources (a sheet range, a database table, or another item) and draws them from window.ARTIFACTS. The page gets window.ARTIFACTS = { read_at, data: { <name>: … }, errors: { <name>: why }, sources: { <name>: { reads, title, url, note } } } before any of its scripts run. A sheet or database source is { kind, from, columns, rows (numbers as numbers), text (as people see them: "$1,234", "12%"), records (each row as an object by column) }; another item is { kind, from, content }. Draw from it in JavaScript (a chart library from a CDN, or your own SVG and tables); never type its numbers into the HTML. Read guide topic "reports" first: it has the classes, with the HTML of each block. Give the head and the first finished part; update_report adds the rest, a section a call. Run it with render_report once it is whole.

Parameters:
- `space_id` (string, required)
- `title` (string, required)
- `sources` (object[])
- `theme` (string): Its fonts and colors. Default paper. Guide topic "reports" says what each is for.
- `html` (string, required): index.html: a whole document that links theme.css. Its head and first finished part; update_report adds the rest.
- `files` (object[]): Files beside it: app.js, JSON, SVG. theme.css is added for you.
- `message` (string)

## read_report

A report as it is now: its files (people's live edits included; numbered: true puts line numbers in front), its version, its sources, and what each source gives the page now — columns and the first rows of a table, or the content of an item. The page gets window.ARTIFACTS = { read_at, data: { <name>: … }, errors: { <name>: why }, sources: { <name>: { reads, title, url, note } } } before any of its scripts run. A sheet or database source is { kind, from, columns, rows (numbers as numbers), text (as people see them: "$1,234", "12%"), records (each row as an object by column) }; another item is { kind, from, content }. Draw from it in JavaScript (a chart library from a CDN, or your own SVG and tables); never type its numbers into the HTML.

Parameters:
- `item_id` (string, required)
- `paths` (string[])
- `numbered` (boolean)
- `data` (boolean): Default true: what each source gives now.

## update_report

Change a report: its files (the same edits as edit_page — replace exact text, write a whole file, delete, rename; index.html stays), its sources, its theme, or any of them. sources, when given, is the whole list in its new form: keep the ones that stay. theme restyles the whole report (its fonts and colors) without touching its HTML. To build an empty report or rewrite one: guide topic "reports" first (the standard look and the HTML of each block), then one section a call. Everyone with it open gets the new report at once; file edits become a new version with your message. read_report first (people may have edited it), render_report after.

Parameters:
- `item_id` (string, required)
- `message` (string, required): What changed, as a commit message.
- `edits` (object[])
- `sources` (object[])
- `theme` (string): Switch its fonts and colors to this theme.

## render_report

Run a report as people see it, with its data read now, and check all of it in one call: JavaScript errors, console errors and failed requests; its layout at desktop and phone widths, in words; pictures of the whole page; sources that could not be read, and Artifacts's and whether it is on the standard look. steps clicks and types through it as in render_page. Call it once the report is built, not after every edit. Fix every error and every source that can't be read before you hand it over.

Parameters:
- `item_id` (string, required)
- `width` (integer): The width the pictures are taken at. Default 1280. The layout is checked at this width and at a phone's (390) either way.
- `height` (integer): Default 800.
- `from_y` (integer): Where the pictures start, in px from the top (default 0). A call shows the whole page, up to eight screens; a longer page says where to continue.
- `pictures` (boolean): false: errors and layout findings only, no pictures. For re-checking after a fix.
- `steps` (object[])
