Skip to main content

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.

Metadata

Release files for pp-rpc-server 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pp-rpc-server 0.2.1
File Size Uploaded
pp_rpc_server-0.2.1.tar.gz 52.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pp-rpc-server 0.2.1
File Interpreter ABI Platform
pp_rpc_server-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 85.0 kB

Release files / pp_rpc_server-0.2.1.tar.gz

Download URL pp_rpc_server-0.2.1.tar.gz
Size 52.6 kB
Tags Source
SHA-256 checksum
How to use checksums
82eb8cffa88d14efede6660ab92b6692ce29640076bd1e9e319aedd392cd971c
BLAKE2b-256 checksum
How to use checksums
8693f3f0b93e05bd112f362dbbbc705e696b7e9e91e91b05d510a40f0836f0dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pp_rpc_server-0.2.1-py3-none-any.whl

Download URL pp_rpc_server-0.2.1-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
377f0c199f2797c6d657210b0d2e9056639000dfe656e39924be2f7b94aa5199
BLAKE2b-256 checksum
How to use checksums
f946174613743a61d738c79a214c51e07c0890b18aa2bda8fcf03a85fcb0ca71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page