run_script
Run a short JavaScript program on this computer that calls several BCD tools in a row and returns only what it logs or returns, in one round trip. Use it for multi-step work (read several files and pick lines, search then read the matches, check then write) instead of calling the tools one by one. Inside, call tools as await tools.read_file({ path }) (same names and arguments as the tools themselves); each returns its result (structured fields plus .text, the text you would have read) and throws when the tool fails. console.log(...) and the returned value come back; sleep(ms) waits. Each call is checked against this computer's permissions and recorded like a direct call. Not available inside: run_script, workflows, shutdown. At most 200 calls; no require/import, network only through tools such as read_url.
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": {
"code": "<code>"
},
"name": "run_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The body of an async function: use await, log with console.log, and optionally return a value | |
| deviceId | No | Computer name or id | |
| workSessionId | No | From create_work_session | |
| timeoutSeconds | No | Stop after this many seconds; calls already made are not undone |