Run new code LIVE in the user's open R3 editor
r3_editor_codeThe same tool as r3_code_write (this is its older name): replace a Code component's code, kept at once in the project's live copy: every R3 tab with the project open runs the new code now, no editor needed and nothing to save. Name it with componentId or entityRef and pass baseVersion, the codeVersion r3_code_read answered: code is never merged, so on an older version it is refused with the current code and version (apply your change to that and call again). A long script can be PATCHED instead: replacements + baseSha256, as r3_code_write takes them. The code is a FUNCTION BODY (a top-level return {start, update};); read r3_docs_read("CODE_PATTERNS.md") for the R3 APIs. A syntax error or an R3 API that does not exist is refused before anything is kept.
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_editor_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | The whole new code (a function body). Omit it when you send replacements. | |
| entityRef | No | Or its entityRef, e.g. "code_spin". | |
| projectId | Yes | The project (r3_project_list). | |
| baseSha256 | No | With replacements only: the sha256 r3_code_read answered for the script (of its WHOLE code) at baseVersion. | |
| baseVersion | No | REQUIRED: the codeVersion r3_editor_inspect gave for this Code component (the version your code builds on); null for one never saved (codeVersion null). | |
| componentId | No | The Code component's id. | |
| replacements | No | Instead of code: exact replacements on the script at baseVersion, in order, all or nothing (at most 200, 60000 characters of old + new in all). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seq | No | ||
| live | Yes | ||
| name | Yes | ||
| error | Yes | ||
| saved | Yes | ||
| 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. | |
| editor | Yes | ||
| sha256 | Yes | ||
| compiled | Yes | ||
| warnings | Yes | ||
| entityRef | Yes | ||
| projectId | Yes | ||
| totalChars | Yes | ||
| codeVersion | Yes | ||
| componentId | Yes |