feat(frontend): xterm.js sur WebSocket avec reconnexion et scrollback (#13)

Lot F3 du chantier server/client mode : le client web branche xterm.js sur
le terminal distant via WebSocket, en face de l'endpoint PTY B5.

- wsLiveClient.ts : transport WebSocket du terminal avec reconnexion.
- streamGateways.ts : gateway terminal (open/attach/data/resize/close).
- frames.ts : frames PTY alignées sur le contrat serveur B5.
- Tests : terminalGateway.test.ts, wsLiveClientReconnect.test.ts.

Validé : frontend 743 tests verts (F3 ciblé 12), cohérence des frames
B5↔F3 confirmée, desktop non régressé.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-15 18:09:25 +02:00
parent 917be995a4
commit 7487902ddb
5 changed files with 685 additions and 61 deletions

View File

@ -94,7 +94,7 @@ export interface ServerFrame {
payload: Record<string, unknown>;
}
/** Payload of a `terminal.attached` acknowledgement. */
/** Payload of a `terminal.attached` acknowledgement (B5, `server.rs`). */
export interface AttachedPayload {
session: {
sessionId: string;
@ -104,8 +104,15 @@ export interface AttachedPayload {
cols: number;
};
nextSeq: number;
/**
* Bounded scrollback replayed at (re)attach. B5 sends a single entry (`seq:0`)
* carrying all retained bytes, or an empty array when there is nothing to
* replay.
*/
scrollback: { seq: number; bytesBase64: string }[];
gap: boolean;
/** Lifecycle status carried on the ack (B5 sends `"running"`). */
status?: string;
/** Conversation id minted by an `agent.launch` (mirrors `assignedConversationId`). */
assignedConversationId?: string;
}
@ -117,6 +124,16 @@ export interface OutputPayload {
bytesBase64: string;
}
/**
* Payload of a `terminal.status` frame (B5). `status` is a lifecycle transition
* (`"exited"` on close); `exitCode` is present for `"exited"` (may be `null`).
*/
export interface StatusPayload {
sessionId: string;
status: string;
exitCode?: number | null;
}
/** Payload of a `chat.output` frame (structured assistant stream). */
export interface ChatOutputPayload {
sessionId: string;