feat(chat): livre la CLI custom de chat agent (#147) et corrige Cancel

Implémente la vue chat structurée par cellule agent (toggle TUI/CLI custom,
préférence persistée `preferred_view`, reattach live, composer + pièces
jointes) avec le socle backend AgentSession/ChatBridge (UserPrompt,
cancel_current_turn, routage interrupt_agent, commande cancel_agent_chat).

Corrige le bug bloquant relevé par QA : le bouton Cancel de
CustomAgentChatView interrompait tout le tour via closeAgentChat au lieu
de n'annuler que le tour courant via cancelAgentChat, ce qui tuait la
session contrairement au contrat produit validé.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-05 11:59:39 +02:00
parent efbd56a149
commit dcba76b871
33 changed files with 1681 additions and 144 deletions

View File

@ -157,6 +157,22 @@ export interface ConversationDetails {
tokenCount?: number;
}
/** A live structured/headless chat session displayed by the custom agent CLI. */
export interface AgentChatHandle {
/** Stable structured session id. */
readonly sessionId: string;
/** Conversation id assigned by launch when the backend minted one. */
readonly assignedConversationId?: string;
}
/** Result of re-attaching a custom chat view to a live structured session. */
export interface ReattachAgentChatResult {
/** Stable structured session id. */
sessionId: string;
/** Retained chunks already streamed for the session. */
scrollback: ReplyChunk[];
}
/** Agents: create, list, read/update context, delete, launch (L6). */
export interface AgentGateway {
/** Lists all agents belonging to the given project. */
@ -243,6 +259,34 @@ export interface AgentGateway {
options: OpenTerminalOptions,
onData: (bytes: Uint8Array) => void,
): Promise<TerminalHandle>;
/**
* Launches an agent through its structured/headless adapter for the custom
* chat CLI. Only profiles carrying `structuredAdapter` are expected to work;
* backends without structured support may omit this method.
*/
launchAgentChat?(
projectId: string,
agentId: string,
options: OpenTerminalOptions,
): Promise<AgentChatHandle>;
/**
* Re-attaches a custom chat view to a still-live structured session, replaying
* retained reply chunks before subsequent live chunks arrive.
*/
reattachAgentChat?(
sessionId: string,
onChunk: (chunk: ReplyChunk) => void,
): Promise<ReattachAgentChatResult>;
/** Sends one user prompt to a live structured session. */
sendAgentChat?(
sessionId: string,
prompt: string,
onChunk: (chunk: ReplyChunk) => void,
): Promise<void>;
/** Interrupts only the current turn of a live structured session. */
cancelAgentChat?(sessionId: string): Promise<void>;
/** Shuts a live structured session down. */
closeAgentChat?(sessionId: string): Promise<void>;
/**
* Re-attaches to an agent's already-running PTY (same backend mechanism as
* {@link TerminalGateway.reattach}; agent sessions share the session-based