Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.declaw.ai/llms.txt

Use this file to discover all available pages before exploring further.

A sequence of seven visual effects generated entirely inside a sandbox VM and streamed byte-for-byte through the PTY to your local terminal. The script uses nothing but Python stdlib and raw ANSI escape codes — no curses, no ncurses, no external deps.

Use case

Stress-test the PTY stream with rapid output, truecolor sequences, cursor movement, and full-screen rewrites. If every effect renders cleanly, you can trust the SSE pipe for any TUI workload an agent might produce.

What you’ll learn

  • Uploading a program with sbx.files.write() to avoid stdin echo
  • 256-colour and 24-bit truecolor rendering via ANSI escapes
  • Animated spinner and progress bar with \r line replacement
  • Box-drawing table output
  • Matrix-style rain with cursor-up rewriting (\e[8A)
  • Combining python3 /tmp/show.py && exit in a single PTY send

Prerequisites

pip install declaw

Code walkthrough

The driver uploads a show program and runs it through one PTY session:
with Sandbox.create(template="python") as sbx:
    sbx.files.write("/tmp/show.py", SHOW_PROGRAM)

    handle = sbx.pty.create(
        size=PtySize(cols=100, rows=32),
        on_data=lambda b: (
            sys.stdout.buffer.write(b),
            sys.stdout.buffer.flush(),
        ),
        timeout=120,
    )
    handle.send_stdin("python3 /tmp/show.py && exit\n")
    result = handle.wait(timeout=60)
The SHOW_PROGRAM (embedded in the source file) runs seven acts:
#EffectTechnique
1Rainbow DECLAW banner256-colour \e[38;5;Nm per character
2Horizontal gradient24-bit truecolor \e[48;2;R;G;Bm
3Braille spinner\r line replace, 40 frames
4Progress bar\r overwrite with % counter
5Box-drawing table+--+ style with colour
6Matrix rain8-row 60-frame animation via \e[8A
7Sign-off messagePlain truecolor text

Running it

Run in an xterm-compatible terminal (iTerm2, Alacritty, Kitty, modern Terminal.app, or any tmux pane):
export DECLAW_API_KEY="your-api-key"
export DECLAW_DOMAIN="api.declaw.ai"
python cookbook/examples/pty-showcase/main.py
The full show takes about 8 seconds. You will see the banner paint character by character, the gradient fill, the spinner tick through its braille frames, the progress bar crawl to 100%, a stats table render, and finally Matrix-style green rain scroll down for a few seconds. The closing message reads:
 every byte you just saw was generated inside a declaw sandbox,
 streamed over SSE, and rendered by your local terminal.

Full source

See cookbook/examples/pty-showcase/main.py in the repo.