Best-effort writer for terminal escape/control sequences.
Centralizes the "fire and forget" pattern the app uses for cosmetic terminal
control (OSC 9;4 taskbar progress today; eventually OSC 52 clipboard and the
iTerm2 cursor guide). Writes prefer /dev/tty so output reaches the terminal
even when stdout/stderr are redirected, fall back to sys.__stderr__, and
never raise — cosmetic control output must not crash the app.
Set DEEPAGENTS_CODE_NO_TERMINAL_ESCAPE=1 to disable all output (useful for
unsupported terminals or noisy logs).
Return whether env var name is set to a recognizably truthy value.
Unlike bool(os.environ.get(name)), this does not treat "0" or
"false" as enabled. Use this for on/off flags where the user would
reasonably expect VAR=0 to mean "disabled".
Best-effort write of a terminal control sequence.
Prefers /dev/tty so the sequence reaches the terminal even when stdout
or stderr are redirected. Falls back to sys.__stderr__ only if it is a
TTY.
Returns False (no-op) when output is disabled or no TTY is reachable.
Write an OSC <command>;<payload> sequence.
Set the terminal's OSC 9;4 progress indicator.
Fires unconditionally — terminals that don't recognize OSC 9;4 silently
ignore the sequence. Set DEEPAGENTS_CODE_NO_TERMINAL_ESCAPE=1 to opt out
entirely.
Clear the terminal's progress indicator.
Emits OSC 9;4;0;0.
Set the terminal's dynamic default background color with OSC 11.
This is cosmetic and intentionally best-effort. Terminals that don't
support OSC 11 ignore it. OSC 111 restores the default background at
shutdown, but only when this call succeeds.
Apple Terminal applies the OSC 11 background but does not restore the
original background on OSC 111. Callers that must not leave a changed
background behind must skip Apple Terminal.
Reset the terminal's dynamic default background color with OSC 111.
This is a no-op when set_terminal_background never succeeded, so the app
does not send a restore for a background it did not change.