/** * Tauri adapter for {@link InputGateway} (ARCHITECTURE ยง20.3). * * `interrupt` โ†’ `interrupt_agent` (preempt). `delegationDelivered` โ†’ * `delegation_delivered` (the native write-portal's ack that a delegation's * text was effectively written into the PTY). The former `submit` โ†’ * `submit_agent_input` path is gone: the agent cell is a native terminal, so * human keystrokes reach the PTY directly (no mediated-input strip). * * Commands use snake_case (Tauri convention); payload keys are camelCase * (matching the backend DTO `#[serde(rename_all = "camelCase")]`), consistent * with the other adapters in this directory. */ import { invoke } from "@tauri-apps/api/core"; import type { InputGateway } from "@/ports"; export class TauriInputGateway implements InputGateway { async interrupt(projectId: string, agentId: string): Promise { await invoke("interrupt_agent", { request: { projectId, agentId }, }); } async delegationDelivered( projectId: string, agentId: string, ticket: string, ): Promise { console.info("[input-gateway] delegationDelivered:start", { projectId, agentId, ticket, }); await invoke("delegation_delivered", { request: { projectId, agentId, ticket }, }); console.info("[input-gateway] delegationDelivered:ok", { projectId, agentId, ticket, }); } async setFrontAttached(agentId: string, attached: boolean): Promise { console.info("[input-gateway] setFrontAttached:start", { agentId, attached }); await invoke("set_front_attached", { request: { agentId, attached }, }); console.info("[input-gateway] setFrontAttached:ok", { agentId, attached }); } async cancelResume(agentId: string): Promise { // `cancel_resume` takes a bare `agent_id` (camelCase `agentId`), not a // `request` envelope, and returns whether a pending resume was disarmed. return invoke("cancel_resume", { agentId }); } async setResumeAt(agentId: string, resetsAtMs: number): Promise { // `set_resume_at` takes bare `agent_id` + `resets_at_ms` (camelCase), like // `cancel_resume`; arms the cancellable resume at the chosen instant. await invoke("set_resume_at", { agentId, resetsAtMs }); } }