A small Python program runs inside the sandbox and renders a full-screen dashboard that refreshes every 500 ms for ~15 seconds. CPU usage, memory, uptime, and a sparkline history are all read fromDocumentation Index
Fetch the complete documentation index at: https://docs.declaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
/proc inside the VM and painted with ANSI cursor-home + overwrite
so the screen never scrolls. Every frame streams through the PTY’s
SSE pipe and your local terminal renders it in place.
Use case
Proof that full-screen TUIs work over the declaw PTY. If a dashboard with in-place refresh, box-drawing characters, and colour-coded bars renders correctly, so willhtop, vim, tmux, and any curses app.
What you’ll learn
- Uploading a script with
sbx.files.write()and running it through the PTY - In-place refresh via ANSI
\e[H(cursor home) without scrolling - Reading real
/proc/stat,/proc/meminfo,/proc/uptimefrom the sandbox VM - Sparkline rendering with Unicode block elements
- Graceful
KeyboardInterrupthandling withhandle.kill()
Prerequisites
Code walkthrough
The driver is short. It uploads a dashboard program to/tmp, runs
it through a PTY, and waits for it to finish:
DASHBOARD_PROGRAM string (embedded in the source file) does
the heavy lifting inside the VM:
- CPU — reads
/proc/stattwice with a 500 ms gap, computes the delta, and derives a percentage. - Memory — reads
MemTotalandMemAvailablefrom/proc/meminfo. - Uptime — reads
/proc/uptime. - Sparkline — maintains a rolling history list and maps each bucket to one of eight Unicode block characters.
- Refresh —
\e[H(cursor home) before every frame so the dashboard overwrites itself in place.
Running it
Ctrl-C at any point to stop early.
Expected output
A single in-place frame looks roughly like this (colours omitted):Full source
Seecookbook/examples/pty-dashboard/main.py in the repo.