perf(server): bound terminal history by bytes (#9748)
Keep at most 5,000 lines and 8 MiB of retained UTF-8 terminal history. Discard the oldest text at either limit while preserving complete live output. Track bytes and newlines in small chunks. Join split surrogates before eviction. Restore only the needed file tail, handle short reads, and close the file before rewriting current or legacy history. Created with GPT-6 Astra (preview) in Codex. Co-authored-by: will <will@moondiner.com>