/** * Wire contract with the ori backend, mirroring internal/bridge/protocol.go. * * ACP payloads (session updates, permission requests) arrive verbatim from * the agent, so their shapes follow https://agentclientprotocol.com. */ /** An ACP content block; only text blocks are rendered in this version. */ export interface AcpContentBlock { type: string; text?: string; [key: string]: unknown; } /** One piece of tool-call output: nested content, a file diff, or a terminal. */ export interface AcpToolCallContent { type: string; content?: AcpContentBlock; path?: string; oldText?: string | null; newText?: string; terminalId?: string; } /** A file location a tool call touches (Zed uses this to "follow the agent"). */ export interface AcpToolCallLocation { path: string; line?: number; } /** One entry of the agent's execution plan. */ export interface AcpPlanEntry { content: string; priority: string; status: string; } /** One choice offered by a permission request. */ export interface AcpPermissionOption { optionId: string; name: string; kind: string; } /** The ACP payload of a session/request_permission call. */ export interface AcpPermissionRequest { sessionId?: string; toolCall?: { toolCallId?: string; title?: string | null; kind?: string; [key: string]: unknown; }; options?: AcpPermissionOption[]; } /** * One ACP session/update notification payload, discriminated by * sessionUpdate. Message/thought chunks use `content` as a single block; * tool calls use it as an array of AcpToolCallContent. */ export interface AcpSessionUpdate { sessionUpdate: string; content?: AcpContentBlock | AcpToolCallContent[]; toolCallId?: string; title?: string | null; kind?: string; status?: string; locations?: AcpToolCallLocation[]; entries?: AcpPlanEntry[]; [key: string]: unknown; } /** A message sent by the server over the WebSocket. */ export interface ServerMessage { type: | "hello" | "user_message" | "session_update" | "permission_request" | "permission_resolved" | "turn_started" | "turn_ended" | "error"; sessionId?: string; turnActive?: boolean; update?: AcpSessionUpdate; requestId?: string; request?: AcpPermissionRequest; text?: string; stopReason?: string; message?: string; } /** A message the browser sends to the server. */ export type ClientMessage = | { type: "prompt"; text: string } | { type: "cancel" } | { type: "permission_response"; requestId: string; optionId?: string; cancelled?: boolean; };