1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/**
* 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;
}
/** One slash command announced by the agent (available_commands_update). */
export interface AcpAvailableCommand {
name: string;
description: string;
input?: { hint?: string } | null;
}
/** 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[];
availableCommands?: AcpAvailableCommand[];
[key: string]: unknown;
}
/**
* A workspace file mentioned in a prompt with "@": the server turns it into
* an ACP resource_link block next to the text. `path` is absolute (as
* returned by the file search), `name` the relative path shown in the text.
*/
export interface PromptAttachment {
path: string;
name: string;
}
/** 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;
attachments?: PromptAttachment[];
stopReason?: string;
message?: string;
}
/** A message the browser sends to the server. */
export type ClientMessage =
| { type: "prompt"; text: string; attachments?: PromptAttachment[] }
| { type: "cancel" }
| {
type: "permission_response";
requestId: string;
optionId?: string;
cancelled?: boolean;
};
|