pi-mono/packages/server
2026-08-13 18:24:27 +03:00
..
src feat(protocol): add service-addressed session RPC 2026-08-13 18:24:27 +03:00
test feat(protocol): add service-addressed session RPC 2026-08-13 18:24:27 +03:00
CHANGELOG.md Add [Unreleased] section for next cycle 2026-08-07 07:48:13 +02:00
package.json feat(protocol): add service-addressed session RPC 2026-08-13 18:24:27 +03:00
README.md feat(protocol): add service-addressed session RPC 2026-08-13 18:24:27 +03:00
tsconfig.build.json chore: rename orchestrator to server (#6898) 2026-07-21 13:32:42 +02:00
tsconfig.test.json feat(protocol): add service-addressed session RPC 2026-08-13 18:24:27 +03:00
vitest.config.ts feat(protocol): add service-addressed session RPC 2026-08-13 18:24:27 +03:00

@earendil-works/pi-server

Experimental local server for the new durable Session and Agent Harness interfaces.

The current slice supports two control-plane operations:

  • list calls SessionRepo.list() without opening sessions.
  • attach finds the requested metadata, calls SessionRepo.open(), creates an AgentHarness, and retains that Harness in the server.

Concurrent attachments to one session reuse one hosted Harness. Losing a client connection removes its attachment but does not close the Harness. Server shutdown closes every hosted Harness, releasing its Session writer ownership.

import { MemorySessionRepo } from "@earendil-works/pi-agent-core";
import type { PiServerService } from "@earendil-works/pi-server";
import { createUnixServer } from "@earendil-works/pi-server/unix";

const sessions = new MemorySessionRepo();
const service: PiServerService = {
  sessions,
  async createHarness(session) {
    return createApplicationHarness({ session });
  },
};

const server = createUnixServer(service, {
  path: "/tmp/pi/server.sock",
  serviceId: loadStableServiceId(),
});
await server.start();

Applications supply the repository and Harness factory. serviceId is a logical identity supplied by the installation or server profile, not a socket address.

PiServer composes authenticated transports through PiServerListener. The Unix submodule provides createUnixListener() and createUnixServer(). Low-level CBOR framing and validation come from @earendil-works/pi-protocol.