save_token_exec
Run persistent JavaScript REPL sessions to execute code, shell commands, and fetch URLs while compacting or indexing large outputs, reducing token use across AI agent turns.
Instructions
Universal token-saving JS REPL across code, data, docs, static web, and CLIs: persists state across turns, runs await $`...`.compact(), tools.fetchText(url), tools.compactOutput(), tools.detectClis(), tools.saveMemory/loadMemory, tools.*, and indexes large output into SQLite FTS5+Trigram.
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": "save_token_exec"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory for relative paths and shell commands. | |
| code | Yes | Async JavaScript body (supports `await`, `return`, `state`, `$`, `tools`, `console`). | |
| mode | No | Safety lock: defaults to 'readonly'. Set to 'write' to allow file edits/writes. | readonly |
| intent | No | BM25 search intent to return only matching chunks when output is large. | |
| timeoutMs | No | Timeout in ms (1000..300000). | |
| resetState | No | Clear in-memory `state` before running. | |
| maxOutputChars | No | Context budget cap (500..32000). |