serena.project_server#
Source code: serena/project_server.py
- class QueryProjectRequest(*, project_name, tool_name, tool_params_json)[source]#
Bases:
BaseModelRequest model for the /query_project endpoint, matching the interface of
QueryProjectTool.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
project_name (str)
tool_name (str)
tool_params_json (str)
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ProjectServer(host='127.0.0.1', port=None)[source]#
Bases:
objectA lightweight Flask server that exposes a SerenaAgent’s project querying capabilities via HTTP, using the LSP language server backend for symbolic retrieval.
Projects are loaded on demand when a query is made for them, and cached in memory for subsequent queries.
The server instantiates a
SerenaAgentwith default options and provides a/query_projectendpoint whose interface matchesQueryProjectTool.- Parameters:
host (str) – the host address to listen on.
port (int | None) – the port to listen on; if None, use default
- class ProjectServerClient(host='127.0.0.1', port=24225, timeout=300)[source]#
Bases:
objectClient for interacting with a running
ProjectServer.Upon instantiation, the client verifies that the server is reachable by sending a heartbeat request. If the server is not running, a
ConnectionErroris raised.- Parameters:
host (str) – the host address of the project server.
port (int) – the port of the project server.
timeout (int)
- Raises:
ConnectionError – if the project server is not reachable.
- query_project(project_name, tool_name, tool_params_json)[source]#
Query a project by executing a Serena tool in its context.
The interface matches
QueryProjectTool.apply.- Parameters:
project_name (str) – the name of the project to query.
tool_name (str) – the name of the tool to execute. The tool must be read-only.
tool_params_json (str) – the parameters to pass to the tool, encoded as a JSON string.
- Returns:
the tool’s result as a string.
- Return type:
str