// Browser terminal client: `import AyTerminal from "agent-yes/terminal"`. // // A self-contained Shadow-DOM widget that renders a LIVE agent-session terminal // on any page — the terminal sibling of AyChannel (channels/browser.ts). It // streams the agent's raw PTY bytes from the serving `ay serve` daemon's SSE // endpoint (`GET /api/tail/?raw=1`) into an xterm.js terminal. // // const t = new AyTerminal({ pid: "12345" }); // token auto-discovered // t.mount(document.getElementById("term")); // inline, or t.mount() to float // // The grid is ALWAYS sized to the agent's NATIVE PTY (via /api/size) and CSS-scaled // to fit the panel — the widget NEVER resizes the agent's real terminal, so opening // or resizing this (secondary) view can't reflow the agent's own/other viewers' TUI. // READ-ONLY by default (a mirror). INTERACTIVE (an explicit opt-in gated on a // send-capable token) additionally forwards keystrokes (→ /api/send), failing closed // to a mirror on a 403. (Explicit viewer-driven PTY renegotiation is future work — it // must go through the daemon's size negotiation, not a raw per-widget /api/resize.) // // The floating widget is a draggable, resizable window with OS-native min/max // controls; `transparent:true` lets it float over page content. xterm + its CSS // are bundled/inlined so the widget is self-contained — no CDN