This cookbook proves that the sandbox PTY is a fully capableDocumentation Index
Fetch the complete documentation index at: https://docs.declaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
xterm-256color terminal. Every byte the shell emits — including
raw ANSI escape sequences — streams back through the SSE pipe and
renders on your local terminal unchanged.
What you’ll learn
- Querying
$TERM,tput colors, andttyinside the sandbox - Rendering the 16-colour and 256-colour ANSI palettes
- Text styles: bold, underline, reverse, blink
- Cursor save/restore and absolute positioning
- Using
tputabstractions alongside raw escape codes - Bracketed-paste toggle and ncurses TTY detection
Prerequisites
Code walkthrough
The script opens a PTY and drives nine mini-tests throughhandle.send_stdin(). A small helper sends a command and sleeps
briefly to let output flush:
1. TERM value + tput
2. ANSI 16-colour palette
3. Text styles
4. 256-colour palette
A 16x16 grid of\e[48;5;Nm background cells covering the full
256-colour cube.
5. Cursor save/restore + absolute move
6-9. tput abstractions, bracketed paste, TTY detection
The remaining sections usetput setaf, toggle bracketed-paste mode,
and confirm test -t 0 reports stdin as a TTY with stty size
matching the requested dimensions.
Running it
How it works
Every escape sequence is generated by the shell running inside the sandbox. The bytes travel through the SSE stream toon_data, which
writes them directly to your local stdout.buffer. Your terminal
emulator does the actual rendering — the SDK never interprets or
strips ANSI codes.
Full source
Seecookbook/examples/pty-features/main.py in the repo.