REPL: add OSC 52 clipboard fallback and graceful degradation (#61151)
When pressing Ctrl-S → Clipboard in REPL history search on a system
without clipboard tools (xsel, xclip, wl-clipboard), a
TaskFailedException stack trace was thrown. This adds:
- `OncePerId{T}`: a new callable struct that caches `initializer(key)`
per mutable key object via WeakKeyDict, for general-purpose per-object
caching
- `has_system_clipboard()` in InteractiveUtils to detect native
clipboard availability per platform
- OSC 52 terminal clipboard support as a fallback, with proper DA1
(Primary Device Attributes) query to detect terminal capability
- Graceful degradation: when neither clipboard mechanism is available,
the Clipboard option is skipped and a friendly message is shown instead
of a stack trace
Fixes #60145
Co-authored-by: Keno Fischer <Keno@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>