Read the code and event binding of R3 Code components
r3_code_readRead back what a Code component actually contains — its full JavaScript source and the event it runs on. r3_code_write reports what it wrote; this reports what is there.
Use it before replacing a script, so an edit builds on the real source instead of overwriting it blind, and after a write whose reply you did not see, to confirm what landed. Call it with NO entityRefs to get every Code component in the project — that is how you find a script again when you never received the entityRef for it.
Each script comes back with its codeVersion: pass it as r3_code_write's baseVersion. The event comes back as a NAME (RENDER_BEFORE, KEY_DOWN, …), which is the same form r3_code_write takes, so you can hand it straight back. r3_component_read reports the same field as a raw number and omits any source over 2000 characters; this is the tool for reading code.
Name ONE entityRef to read it in pages (offset / length): every script comes back with totalChars, the sha256 of its WHOLE source, and truncated / nextOffset. When truncated is true you have only part of it: read on from nextOffset, join the pages and check the sha256 before writing it back. Reading several, a body longer than one page is left out WHOLE and named with its size — never cut silently, because a partial script written back would delete the rest of it. An entityRef that does not exist is named and the others are still read.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"projectId": "<projectId>"
},
"name": "r3_code_read"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| length | No | How many characters to read at most (default and maximum 60000; 8000 in an R3 Builder session). A page ends on a whole line when it can. | |
| offset | No | Where to start reading, in characters (default 0). For the next page pass the nextOffset of the previous answer. | |
| projectId | Yes | The project to read from, from r3_project_create or r3_project_load. | |
| entityRefs | No | Which Code components to read, e.g. ["spin"]. Omit for ALL of them. Up to 50 per call. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| answer | Yes | This answer in words: what was done, what R3 measured, decided or refused, and what to do next. The same text as the result's text block. Read it: the fields beside it are the data, this is the guidance. | |
| projectId | Yes | ||
| components | Yes | ||
| unreadable | Yes | ||
| projectName | Yes |