FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: add protocol method for `session/set_config_option` by Nemtecl · Pull Request #69 · agentclientprotocol/python-sdk · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (6) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 4 additions & 0 deletions src/acp/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
RequestPermissionRequest,
RequestPermissionResponse,
SessionNotification,
SetSessionConfigOptionRequest,
SetSessionConfigOptionResponse,
SetSessionModelRequest,
SetSessionModelResponse,
SetSessionModeRequest,
Expand Down Expand Up @@ -115,6 +117,8 @@
"SetSessionModeResponse",
"SetSessionModelRequest",
"SetSessionModelResponse",
"SetSessionConfigOptionRequest",
"SetSessionConfigOptionResponse",
# terminal types
"CreateTerminalRequest",
"CreateTerminalResponse",
Expand Down
8 changes: 8 additions & 0 deletions src/acp/agent/router.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
NewSessionRequest,
PromptRequest,
ResumeSessionRequest,
SetSessionConfigOptionRequest,
SetSessionModelRequest,
SetSessionModeRequest,
)
Expand Down Expand Up @@ -53,6 +54,13 @@ def build_agent_router(agent: Agent, use_unstable_protocol: bool = False) -> Mes
adapt_result=normalize_result,
unstable=True,
)
router.route_request(
AGENT_METHODS["session_set_config_option"],
SetSessionConfigOptionRequest,
agent,
"set_config_option",
adapt_result=normalize_result,
)
router.route_request(
AGENT_METHODS["authenticate"],
AuthenticateRequest,
Expand Down
15 changes: 15 additions & 0 deletions src/acp/client/connection.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
ResourceContentBlock,
ResumeSessionRequest,
ResumeSessionResponse,
SetSessionConfigOptionRequest,
SetSessionConfigOptionResponse,
SetSessionModelRequest,
SetSessionModelResponse,
SetSessionModeRequest,
Expand Down Expand Up @@ -150,6 +152,19 @@ async def set_session_model(self, model_id: str, session_id: str, **kwargs: Any)
SetSessionModelResponse,
)

@param_model(SetSessionConfigOptionRequest)
async def set_config_option(
self, config_id: str, session_id: str, value: str, **kwargs: Any
) -> SetSessionConfigOptionResponse:
return await request_model_from_dict(
self._conn,
AGENT_METHODS["session_set_config_option"],
SetSessionConfigOptionRequest(
config_id=config_id, session_id=session_id, value=value, field_meta=kwargs or None
),
SetSessionConfigOptionResponse,
)

@param_model(AuthenticateRequest)
async def authenticate(self, method_id: str, **kwargs: Any) -> AuthenticateResponse:
return await request_model_from_dict(
Expand Down
7 changes: 7 additions & 0 deletions src/acp/interfaces.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
ResumeSessionResponse,
SessionInfoUpdate,
SessionNotification,
SetSessionConfigOptionRequest,
SetSessionConfigOptionResponse,
SetSessionModelRequest,
SetSessionModelResponse,
SetSessionModeRequest,
Expand Down Expand Up @@ -179,6 +181,11 @@ async def set_session_model(
self, model_id: str, session_id: str, **kwargs: Any
) -> SetSessionModelResponse | None: ...

@param_model(SetSessionConfigOptionRequest)
async def set_config_option(
self, config_id: str, session_id: str, value: str, **kwargs: Any
) -> SetSessionConfigOptionResponse | None: ...

@param_model(AuthenticateRequest)
async def authenticate(self, method_id: str, **kwargs: Any) -> AuthenticateResponse | None: ...

Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
RequestError,
RequestPermissionResponse,
SessionNotification,
SetSessionConfigOptionResponse,
SetSessionModeResponse,
TerminalOutputResponse,
WaitForTerminalExitResponse,
Expand Down Expand Up @@ -276,6 +277,11 @@ async def cancel(self, session_id: str, **kwargs: Any) -> None:
async def set_session_mode(self, mode_id: str, session_id: str, **kwargs: Any) -> SetSessionModeResponse | None:
return SetSessionModeResponse()

async def set_config_option(
self, config_id: str, session_id: str, value: str, **kwargs: Any
) -> SetSessionConfigOptionResponse | None:
return SetSessionConfigOptionResponse(config_options=[])

async def ext_method(self, method: str, params: dict) -> dict:
self.ext_calls.append((method, params))
if method == "example.com/echo":
Expand Down
10 changes: 10 additions & 0 deletions tests/test_rpc.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
PromptResponse,
RequestPermissionRequest,
RequestPermissionResponse,
SetSessionConfigOptionResponse,
SetSessionModeResponse,
WriteTextFileResponse,
spawn_agent_process,
Expand Down Expand Up @@ -253,6 +254,15 @@ async def test_set_session_mode_and_extensions(connect, agent, client):
assert client.ext_calls and client.ext_calls[-1] == ("example.com/ping", {"k": 3})


@pytest.mark.asyncio
async def test_set_config_option(connect, agent, client):
_, agent_conn = connect()

resp = await agent_conn.set_config_option(session_id="sess", config_id="theme", value="dark")
assert isinstance(resp, SetSessionConfigOptionResponse)
assert resp.config_options == []


@pytest.mark.asyncio
async def test_ignore_invalid_messages(connect, server):
connect(connect_agent=True, connect_client=False)
Expand Down

Back | FazBrowse Home | New Git URL