pi-server
Experimental. This package is under active development and may change or be removed without notice. Its APIs and behavior are not yet stable.
Server package for pi.
Session server core
The package exports the PiServer session server.
from typing import Any
from pi_server import CreateSessionOptions, PiServerService
from pi_server.transports.unix import UnixServerOptions, create_unix_server
class Service(PiServerService):
async def list_sessions(self) -> list[dict[str, Any]]:
return []
async def list_models(self) -> list[dict[str, Any]]:
return []
async def create_session(self, options: CreateSessionOptions):
raise NotImplementedError
async def open_session(self, session_id: str):
raise NotImplementedError
async def main() -> None:
service = Service()
server = create_unix_server(service, UnixServerOptions(path=".scratch/pi-server.sock"))
await server.start()
PiServer composes transport listeners through the PiServerListener protocol. Each listener must complete any transport-specific authentication and authorization before passing a connection to PiServer. For example, a WebSocket listener can validate credentials during the HTTP upgrade, while the Unix listener relies on socket filesystem permissions. The Unix submodule exports the create_unix_listener() building block and create_unix_server() preset, keeping the common case concise without coupling the primary server to Unix sockets. The listener uses length-prefixed CBOR messages from pi_protocol.
This package does not provide a standalone CLI or coding-agent service. Applications supply the PiServerService implementation.
PiServerService.list_sessions() returns protocol SessionMetadata, not acquired runtime state. Services should map the durable fields their storage supports and may omit updatedAt, parentSessionId, sessionName, and cwd. PiServer refreshes available metadata from live snapshots without requiring stored sessions to fabricate phase, model, thinking-level, attachment, or lock values.
The real coding-agent service boundary lives in pi_coding_agent.core.agent_session_runtime. pi_server itself does not depend on pi_coding_agent.
Transport testing
Custom transports can use pi_server.testing for deterministic protocol conformance tests. It exports create_test_server(), TestServerService, TestSessionRuntime, ProtocolTestClient, and the transport-neutral WireChannel contract. connect_unix_test_client() is provided for Unix transport tests.
from pi_server import PiServerOptions
from pi_server.testing import TestServerService, create_test_server
async def main() -> None:
service = TestServerService()
harness = create_test_server(PiServerOptions(listeners=[]), service)
await harness.server.start()
await harness.server.close()
pi-ai protocol bridge
pi_ai domain objects and pi_protocol wire DTOs remain independent. This package owns their boundary and exports to_protocol_model_metadata(), to_protocol_assistant_message(), to_protocol_user_message(), and to_protocol_tool_result_message().
The adapters reject invalid tool inputs, identifiers, timestamps, and mismatched tool results; to_protocol_tool_result_message() requires the original ToolCall so it can verify the association and convert its arguments itself. Diagnostic details are explicitly sanitized. Closed pi_ai unions are mapped exhaustively. The protocol mirrors pi_ai vocabulary such as toolCall and toolUse where the semantics are identical. Protocol schemas enforce consistent lifecycle states, and tests encode adapter output through the runtime schemas so incompatible changes fail in the bridging package.
Development
From the repository root:
uv sync --all-packages
uv run pytest packages/pi-server
uv run ruff check packages/pi-server
pp-rpc-server is developed in HSPK/pp_rpc_server. It was split out of the pp monorepo; sibling packages (pp-ai, pp-agent-core, pp-tui, pp-coding-agent, ...) each live in their own
repository and are consumed from PyPI.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pp_rpc_server-0.1.0.tar.gz.
File metadata
- Download URL: pp_rpc_server-0.1.0.tar.gz
- Upload date:
- Size: 52.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cffe164b100141c6cec7c0a34d3915768a8d642fd026139d837cb5eb0b41df2e
|
|
| MD5 |
98b46e6a7a67087dc336f1fcca05b5d2
|
|
| BLAKE2b-256 |
09df5ba0635f7e808d18713db6c53c8e58575dc98596fef810176cf04ac95741
|
Provenance
The following attestation bundles were made for pp_rpc_server-0.1.0.tar.gz:
Publisher:
release.yml on HSPK/pp_rpc_server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pp_rpc_server-0.1.0.tar.gz -
Subject digest:
cffe164b100141c6cec7c0a34d3915768a8d642fd026139d837cb5eb0b41df2e - Sigstore transparency entry: 2466720210
- Sigstore integration time:
-
Permalink:
HSPK/pp_rpc_server@a2c8245c8486b224dc70abc24b4968488f43afe3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/HSPK
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a2c8245c8486b224dc70abc24b4968488f43afe3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pp_rpc_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pp_rpc_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e64f7832c18779e22deb3812f5c3cb3d73d5d1ba962ce4a97c442ec5c3979e8c
|
|
| MD5 |
a4976fa9429f08be7d5336529d2d68f0
|
|
| BLAKE2b-256 |
bd875407725374a697ec1ff488f5a1be3ec6011b3d9b8c62bd194d1d6176d8f4
|
Provenance
The following attestation bundles were made for pp_rpc_server-0.1.0-py3-none-any.whl:
Publisher:
release.yml on HSPK/pp_rpc_server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pp_rpc_server-0.1.0-py3-none-any.whl -
Subject digest:
e64f7832c18779e22deb3812f5c3cb3d73d5d1ba962ce4a97c442ec5c3979e8c - Sigstore transparency entry: 2466720243
- Sigstore integration time:
-
Permalink:
HSPK/pp_rpc_server@a2c8245c8486b224dc70abc24b4968488f43afe3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/HSPK
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a2c8245c8486b224dc70abc24b4968488f43afe3 -
Trigger Event:
push
-
Statement type: