# Panel File Get Tool

`panel_file_get` reads the text of one file of a panel version: its main HTML, a script, a stylesheet or an SVG image, or a vendor library the version lists.

## When to Use

The agent uses it before patching an asset other than the main HTML with `panel_update`, so the lines a patch copies are the asset's current lines.

## Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `panel` | string | Yes | The panel's id |
| `file` | string | Yes | The asset's name in the version, as `panel_get` lists it in `files`, such as `app.js`; or a vendor identifier the version lists, such as `verdalia-ui.js` |
| `version` | string | No | The id of the version to read from. Left out, the version people see |
| `offset` | integer | No | How many characters of the file's text to skip: `0` (the default), or `next_offset` of the previous answer |
| `limit` | integer | No | The most characters of text to return, from `1` to `20,000`. Left out, `20,000` |

## Returns

| Field | Type | Description |
|-------|------|-------------|
| `version` | string | The id of the version read |
| `asset` | string or null | The asset's id; `null` for a vendor library, whose text comes with Verdalia |
| `name` | string | The file's name |
| `kind` | string | `html`, `js`, `css` or `svg` |
| `hash` | string | The SHA-256 of its text |
| `bytes` | integer | Its size |
| `content` | string | The file's text from `offset`: at most `limit` characters |
| `total_chars` | integer | The length of the file's whole text in characters |
| `next_offset` | integer or null | The offset of the text after `content`; `null` when `content` reaches the end |

## Example Scenario

```json
{ "panel": "01JC4Z8Q2V6M3K9T1R5X7B0N4D", "file": "app.js" }
```

## Notes

- One call answers at most 20,000 characters, whoever calls. A longer file is read in parts by calling again with `offset` set to `next_offset` until it is `null`
- A `limit` below `1` or above `20,000` is refused; an `offset` at or past the end answers empty `content`
- A name the version does not hold is refused: `Version <id> has no file named <name>`; a vendor library the version does not list is refused the same way
- A version id the panel does not have is refused: `The panel has no version with the id <id>`
- A panel the workspace does not have is refused: `No panel has the id <id>`
- Risk: read
