Skip to content

Commit df1865e

Browse files
committed
fix type issues
1 parent 6304cc0 commit df1865e

File tree

3 files changed

+56
-23
lines changed

3 files changed

+56
-23
lines changed

src/vcode/acp/agent.py

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
from __future__ import annotations as _annotations
22

33
from pathlib import Path
4+
from typing import Any, TypeAlias
45
from uuid import uuid4
56

67
from acp import PROTOCOL_VERSION, Agent, RequestError, update_agent_message_text
78
from acp.interfaces import Client
89
from acp.schema import (
910
AgentCapabilities,
1011
AllowedOutcome,
12+
AudioContentBlock,
1113
AuthenticateResponse,
1214
CloseSessionResponse,
15+
EmbeddedResourceContentBlock,
1316
ForkSessionResponse,
17+
HttpMcpServer,
18+
ImageContentBlock,
1419
Implementation,
1520
InitializeResponse,
1621
ListSessionsResponse,
1722
LoadSessionResponse,
23+
McpServerStdio,
1824
NewSessionResponse,
1925
PromptCapabilities,
2026
PromptResponse,
27+
ResourceContentBlock,
2128
ResumeSessionResponse,
2229
SessionCapabilities,
2330
SessionForkCapabilities,
@@ -27,6 +34,8 @@
2734
SetSessionConfigOptionResponse,
2835
SetSessionModelResponse,
2936
SetSessionModeResponse,
37+
SseMcpServer,
38+
TextContentBlock,
3039
)
3140

3241
from vcode import __version__
@@ -51,6 +60,15 @@
5160

5261
__all__ = ("VCodeAcpAgent",)
5362

63+
McpServerConfigEntry: TypeAlias = HttpMcpServer | SseMcpServer | McpServerStdio
64+
PromptBlock: TypeAlias = (
65+
TextContentBlock
66+
| ImageContentBlock
67+
| AudioContentBlock
68+
| ResourceContentBlock
69+
| EmbeddedResourceContentBlock
70+
)
71+
5472

5573
class VCodeAcpAgent(Agent):
5674
client: Client | None
@@ -69,7 +87,7 @@ async def initialize(
6987
protocol_version: int,
7088
client_capabilities=None,
7189
client_info=None,
72-
**kwargs: object,
90+
**kwargs: Any,
7391
) -> InitializeResponse:
7492
del protocol_version, client_capabilities, client_info, kwargs
7593
return InitializeResponse(
@@ -90,12 +108,15 @@ async def initialize(
90108
agent_info=Implementation(name="vcode", title="vCode", version=__version__),
91109
)
92110

93-
async def authenticate(self, method_id: str, **kwargs: object) -> AuthenticateResponse | None:
111+
async def authenticate(self, method_id: str, **kwargs: Any) -> AuthenticateResponse | None:
94112
del method_id, kwargs
95113
return AuthenticateResponse()
96114

97115
async def new_session(
98-
self, cwd: str, mcp_servers: list[object] | None = None, **kwargs: object
116+
self,
117+
cwd: str,
118+
mcp_servers: list[McpServerConfigEntry] | None = None,
119+
**kwargs: Any,
99120
) -> NewSessionResponse:
100121
del mcp_servers, kwargs
101122
record = self.runtime.create_session(Path(cwd))
@@ -112,8 +133,8 @@ async def fork_session(
112133
self,
113134
cwd: str,
114135
session_id: str,
115-
mcp_servers: list[object] | None = None,
116-
**kwargs: object,
136+
mcp_servers: list[McpServerConfigEntry] | None = None,
137+
**kwargs: Any,
117138
) -> ForkSessionResponse:
118139
del mcp_servers, kwargs
119140
record = self.runtime.clone_session(Path(cwd), session_id)
@@ -132,8 +153,8 @@ async def load_session(
132153
self,
133154
cwd: str,
134155
session_id: str,
135-
mcp_servers: list[object] | None = None,
136-
**kwargs: object,
156+
mcp_servers: list[McpServerConfigEntry] | None = None,
157+
**kwargs: Any,
137158
) -> LoadSessionResponse | None:
138159
del mcp_servers, kwargs
139160
workspace = Path(cwd)
@@ -153,8 +174,8 @@ async def resume_session(
153174
self,
154175
cwd: str,
155176
session_id: str,
156-
mcp_servers: list[object] | None = None,
157-
**kwargs: object,
177+
mcp_servers: list[McpServerConfigEntry] | None = None,
178+
**kwargs: Any,
158179
) -> ResumeSessionResponse:
159180
response = await self.load_session(cwd, session_id, mcp_servers, **kwargs)
160181
if response is None:
@@ -169,7 +190,7 @@ async def list_sessions(
169190
self,
170191
cursor: str | None = None,
171192
cwd: str | None = None,
172-
**kwargs: object,
193+
**kwargs: Any,
173194
) -> ListSessionsResponse:
174195
del cursor, kwargs
175196
workspace = Path(cwd or Path.cwd()).resolve()
@@ -189,7 +210,7 @@ async def set_session_mode(
189210
self,
190211
mode_id: str,
191212
session_id: str,
192-
**kwargs: object,
213+
**kwargs: Any,
193214
) -> SetSessionModeResponse | None:
194215
del kwargs
195216
workspace = self.session_roots.get(session_id)
@@ -210,7 +231,7 @@ async def set_session_model(
210231
self,
211232
model_id: str,
212233
session_id: str,
213-
**kwargs: object,
234+
**kwargs: Any,
214235
) -> SetSessionModelResponse | None:
215236
del kwargs
216237
workspace = self.session_roots.get(session_id)
@@ -234,7 +255,7 @@ async def set_config_option(
234255
config_id: str,
235256
session_id: str,
236257
value: str | bool,
237-
**kwargs: object,
258+
**kwargs: Any,
238259
) -> SetSessionConfigOptionResponse | None:
239260
del kwargs
240261
workspace = self.session_roots.get(session_id)
@@ -277,9 +298,13 @@ async def set_config_option(
277298
)
278299

279300
async def prompt(
280-
self, prompt: list[object], session_id: str, **kwargs: object
301+
self,
302+
prompt: list[PromptBlock],
303+
session_id: str,
304+
message_id: str | None = None,
305+
**kwargs: Any,
281306
) -> PromptResponse:
282-
del kwargs
307+
del kwargs, message_id
283308
workspace = self.session_roots.get(session_id)
284309
if workspace is None:
285310
raise RequestError.invalid_params({"message": "Session not found"})
@@ -298,10 +323,10 @@ async def prompt(
298323

299324
return PromptResponse(stop_reason=result.stop_reason)
300325

301-
async def cancel(self, session_id: str, **kwargs: object) -> None:
326+
async def cancel(self, session_id: str, **kwargs: Any) -> None:
302327
del session_id, kwargs
303328

304-
async def close_session(self, session_id: str, **kwargs: object) -> CloseSessionResponse | None:
329+
async def close_session(self, session_id: str, **kwargs: Any) -> CloseSessionResponse | None:
305330
del kwargs
306331
self.session_roots.pop(session_id, None)
307332
return CloseSessionResponse()

src/vcode/acp/permissions.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,23 @@
2121

2222

2323
def build_permission_tool_call(request: ApprovalRequest, request_id: str) -> ToolCallProgress:
24-
raw_input: dict[str, object] = request.raw_input or {
25-
"target": request.target,
26-
"reason": request.reason,
27-
}
24+
raw_input: dict[str, object]
25+
if request.raw_input is None:
26+
raw_input = {
27+
"target": request.target,
28+
"reason": request.reason,
29+
}
30+
else:
31+
raw_input = dict(request.raw_input)
2832
locations: list[ToolCallLocation] | None = None
2933
title = request.title or request.tool_name
3034
content: list[ContentToolCallContent | FileEditToolCallContent | TerminalToolCallContent]
3135

3236
if request.tool_name == "write_file":
33-
raw_input = request.raw_input or {"path": request.target}
37+
if request.raw_input is None:
38+
raw_input = {"path": request.target}
39+
else:
40+
raw_input = dict(request.raw_input)
3441
locations = [ToolCallLocation(path=request.target)]
3542
content = [
3643
tool_diff_content(

src/vcode/acp/updates.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations as _annotations
22

33
import asyncio
4+
from collections.abc import Sequence
45
from pathlib import Path
56

67
from acp import update_agent_message_text, update_user_message_text
@@ -34,7 +35,7 @@
3435
)
3536

3637

37-
def build_text_prompt(prompt: list[object]) -> str:
38+
def build_text_prompt(prompt: Sequence[object]) -> str:
3839
parts: list[str] = []
3940
for block in prompt:
4041
if isinstance(block, TextContentBlock) and block.text:

0 commit comments

Comments
 (0)