chore: rename orchestrator to server (#6898)

This commit is contained in:
Cristina Poncela Cubeiro
2026-07-21 13:32:42 +02:00
committed by GitHub
parent 9e7582aa03
commit 8495f9d0d6
20 changed files with 79 additions and 80 deletions
@@ -2,6 +2,10 @@
## [Unreleased]
### Changed
- Renamed the orchestrator workspace package and internal server references to server.
## [0.80.10] - 2026-07-16
## [0.80.9] - 2026-07-16
@@ -1,11 +1,11 @@
# @earendil-works/pi-orchestrator
# @earendil-works/pi-server
Experimental. This package is under active development and may change or be removed without notice. Its CLI, APIs, and behavior are not yet stable.
Orchestrator package for pi.
Server package for pi.
## CLI
```bash
orchestrator --help
server --help
```
@@ -1,7 +1,7 @@
{
"name": "@earendil-works/pi-orchestrator",
"name": "@earendil-works/pi-server",
"version": "0.80.10",
"description": "experimental orchestrator package for pi",
"description": "experimental server package for pi",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -11,6 +11,9 @@
"import": "./dist/index.js"
}
},
"bin": {
"server": "./dist/cli.js"
},
"files": [
"dist",
"README.md",
@@ -24,14 +27,14 @@
},
"keywords": [
"pi",
"orchestrator"
"server"
],
"author": "Earendil Works",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/earendil-works/pi.git",
"directory": "packages/orchestrator"
"directory": "packages/server"
},
"engines": {
"node": ">=22.19.0"
@@ -18,7 +18,7 @@ const packageJson = JSON.parse(readFileSync(join(__dirname, "../package.json"),
function printHelp(): void {
console.log(
`orchestrator v${packageJson.version}\n\nUsage:\n orchestrator serve\n orchestrator list\n orchestrator spawn [--cwd <path>] [--label <label>]\n orchestrator status <instance-id>\n orchestrator stop <instance-id>\n orchestrator rpc <instance-id> <json-command>\n orchestrator rpc-stream <instance-id>\n orchestrator --help\n orchestrator --version\n\nRPC stream stdin expects JSONL RpcCommand or extension_ui_response messages.`,
`server v${packageJson.version}\n\nUsage:\n server serve\n server list\n server spawn [--cwd <path>] [--label <label>]\n server status <instance-id>\n server stop <instance-id>\n server rpc <instance-id> <json-command>\n server rpc-stream <instance-id>\n server --help\n server --version\n\nRPC stream stdin expects JSONL RpcCommand or extension_ui_response messages.`,
);
}
@@ -109,7 +109,7 @@ async function main(): Promise<void> {
if (args[0] === "status") {
const instanceId = args[1];
if (!instanceId) {
console.error("Usage: orchestrator status <instance-id>");
console.error("Usage: server status <instance-id>");
process.exit(1);
}
printResponse(await sendIpcRequest({ type: "status", instanceId }));
@@ -119,7 +119,7 @@ async function main(): Promise<void> {
if (args[0] === "stop") {
const instanceId = args[1];
if (!instanceId) {
console.error("Usage: orchestrator stop <instance-id>");
console.error("Usage: server stop <instance-id>");
process.exit(1);
}
printResponse(await sendIpcRequest({ type: "stop", instanceId }));
@@ -130,7 +130,7 @@ async function main(): Promise<void> {
const instanceId = args[1];
const commandJson = args[2];
if (!instanceId || !commandJson) {
console.error("Usage: orchestrator rpc <instance-id> <json-command>");
console.error("Usage: server rpc <instance-id> <json-command>");
process.exit(1);
}
printResponse(
@@ -146,7 +146,7 @@ async function main(): Promise<void> {
if (args[0] === "rpc-stream") {
const instanceId = args[1];
if (!instanceId) {
console.error("Usage: orchestrator rpc-stream <instance-id>");
console.error("Usage: server rpc-stream <instance-id>");
process.exit(1);
}
await rpcStream(instanceId);
@@ -4,7 +4,7 @@ import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const CONFIG_DIR_NAME = ".pi";
const ENV_ORCHESTRATOR_DIR = "PI_ORCHESTRATOR_DIR";
const ENV_SERVER_DIR = "PI_SERVER_DIR";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@@ -42,28 +42,28 @@ try {
export const VERSION: string = pkg.version || "0.0.0";
export function getOrchestratorDir(): string {
const envDir = process.env[ENV_ORCHESTRATOR_DIR];
export function getServerDir(): string {
const envDir = process.env[ENV_SERVER_DIR];
if (envDir) {
return envDir;
}
const piDir = process.env.PI_CONFIG_DIR || join(homedir(), CONFIG_DIR_NAME);
return join(piDir, "orchestrator");
return join(piDir, "server");
}
export function getAuthPath(): string {
return join(getOrchestratorDir(), "auth.json");
return join(getServerDir(), "auth.json");
}
export function getMachinePath(): string {
return join(getOrchestratorDir(), "machine.json");
return join(getServerDir(), "machine.json");
}
export function getInstancesPath(): string {
return join(getOrchestratorDir(), "instances.json");
return join(getServerDir(), "instances.json");
}
export function getSocketPath(): string {
return join(getOrchestratorDir(), "orchestrator.sock");
return join(getServerDir(), "server.sock");
}
@@ -10,12 +10,12 @@ import type {
InstanceSummary,
ListRequest,
ListResponse,
OrchestratorRequest,
OrchestratorResponse,
RpcBridgeResponse,
RpcReadyResponse,
RpcRequest,
RpcStreamRequest,
ServerRequest,
ServerResponse,
SpawnRequest,
SpawnResponse,
StatusRequest,
@@ -53,8 +53,8 @@ export async function handleIpcRequest(request: StopRequest): Promise<StopRespon
export async function handleIpcRequest(request: StatusRequest): Promise<StatusResponse | ErrorResponse>;
export async function handleIpcRequest(request: RpcRequest): Promise<RpcBridgeResponse | ErrorResponse>;
export async function handleIpcRequest(request: RpcStreamRequest): Promise<RpcReadyResponse | ErrorResponse>;
export async function handleIpcRequest(request: OrchestratorRequest): Promise<OrchestratorResponse>;
export async function handleIpcRequest(request: OrchestratorRequest): Promise<OrchestratorResponse> {
export async function handleIpcRequest(request: ServerRequest): Promise<ServerResponse>;
export async function handleIpcRequest(request: ServerRequest): Promise<ServerResponse> {
switch (request.type) {
case "spawn": {
const instance = await supervisor.spawnInstance({
@@ -1,11 +1,11 @@
import { createConnection } from "node:net";
import { getSocketPath } from "../config.ts";
import { encodeMessage, type OrchestratorRequest, type OrchestratorResponse, parseResponseLine } from "./protocol.ts";
import { encodeMessage, parseResponseLine, type ServerRequest, type ServerResponse } from "./protocol.ts";
export async function sendIpcRequest(request: OrchestratorRequest): Promise<OrchestratorResponse> {
export async function sendIpcRequest(request: ServerRequest): Promise<ServerResponse> {
const socketPath = getSocketPath();
return new Promise<OrchestratorResponse>((resolve, reject) => {
return new Promise<ServerResponse>((resolve, reject) => {
const socket = createConnection(socketPath);
let buffer = "";
let settled = false;
@@ -56,7 +56,7 @@ export async function sendIpcRequest(request: OrchestratorRequest): Promise<Orch
return;
}
settled = true;
reject(new Error(`Orchestrator socket closed before a response was received: ${socketPath}`));
reject(new Error(`Server socket closed before a response was received: ${socketPath}`));
cleanup();
});
});
@@ -49,7 +49,7 @@ export interface RequestMap {
rpc_stream: RpcStreamRequest;
}
export type OrchestratorRequest = RequestMap[keyof RequestMap];
export type ServerRequest = RequestMap[keyof RequestMap];
export interface InstanceSummary {
id: string;
@@ -111,7 +111,7 @@ export interface ResponseMap {
rpc_stream: RpcReadyResponse;
}
export type OrchestratorResponse = ResponseMap[keyof ResponseMap] | ErrorResponse;
export type ServerResponse = ResponseMap[keyof ResponseMap] | ErrorResponse;
export type RpcClientMessage = RpcCommand | RpcExtensionUIResponse;
export type RpcServerMessage =
| RpcReadyResponse
@@ -119,9 +119,9 @@ export type RpcServerMessage =
| AgentSessionEvent
| RpcExtensionUIRequest
| ErrorResponse;
export type ProtocolMessage = OrchestratorRequest | OrchestratorResponse | RpcClientMessage | RpcServerMessage;
export type ProtocolMessage = ServerRequest | ServerResponse | RpcClientMessage | RpcServerMessage;
export type ResponseFor<T extends OrchestratorRequest> = T extends { type: infer K }
export type ResponseFor<T extends ServerRequest> = T extends { type: infer K }
? K extends keyof ResponseMap
? ResponseMap[K] | ErrorResponse
: ErrorResponse
@@ -131,12 +131,12 @@ export function encodeMessage(message: ProtocolMessage): string {
return `${JSON.stringify(message)}\n`;
}
export function parseRequestLine(line: string): OrchestratorRequest {
const value = JSON.parse(line) as OrchestratorRequest;
export function parseRequestLine(line: string): ServerRequest {
const value = JSON.parse(line) as ServerRequest;
return value;
}
export function parseResponseLine(line: string): OrchestratorResponse {
const value = JSON.parse(line) as OrchestratorResponse;
export function parseResponseLine(line: string): ServerResponse {
const value = JSON.parse(line) as ServerResponse;
return value;
}
@@ -7,13 +7,13 @@ import {
encodeMessage,
type ListRequest,
type ListResponse,
type OrchestratorRequest,
type OrchestratorResponse,
parseRequestLine,
type RpcBridgeResponse,
type RpcReadyResponse,
type RpcRequest,
type RpcStreamRequest,
type ServerRequest,
type ServerResponse,
type SpawnRequest,
type SpawnResponse,
type StatusRequest,
@@ -29,7 +29,7 @@ export interface IpcRequestHandler {
(request: StatusRequest): Promise<StatusResponse | ErrorResponse> | StatusResponse | ErrorResponse;
(request: RpcRequest): Promise<RpcBridgeResponse | ErrorResponse> | RpcBridgeResponse | ErrorResponse;
(request: RpcStreamRequest): Promise<RpcReadyResponse | ErrorResponse> | RpcReadyResponse | ErrorResponse;
(request: OrchestratorRequest): Promise<OrchestratorResponse> | OrchestratorResponse;
(request: ServerRequest): Promise<ServerResponse> | ServerResponse;
openRpcStream(
instanceId: string,
onResponse: (response: RpcResponse) => void,
@@ -166,7 +166,7 @@ async function removeStaleSocketIfNeeded(socketPath: string): Promise<void> {
const isLive = await isSocketLive(socketPath);
if (isLive) {
throw new Error(`orchestrator is already running: ${socketPath}`);
throw new Error(`server is already running: ${socketPath}`);
}
unlinkSync(socketPath);
@@ -1,12 +1,12 @@
import { hostname, platform } from "node:os";
import type { OAuthCredential } from "@earendil-works/pi-ai";
import { readStoredCredential } from "@earendil-works/pi-coding-agent";
import { getOrchestratorDir, getSocketPath, VERSION } from "./config.ts";
import { getServerDir, getSocketPath, VERSION } from "./config.ts";
import { loadMachine, saveMachine } from "./storage.ts";
import type { InstanceRecord, MachineRecord, RadiusRegistration } from "./types.ts";
const DEFAULT_RADIUS_URL = "https://radius.pi.dev/";
const DEFAULT_ORCHESTRATOR_BASE_PATH = "/v1/";
const DEFAULT_SERVER_BASE_PATH = "/v1/";
const NOT_FOUND_RETRY_THRESHOLD = 3;
const HEARTBEAT_BACKOFF_BASE_MS = 1_000;
const HEARTBEAT_BACKOFF_MAX_MS = 30_000;
@@ -45,7 +45,7 @@ class RadiusHttpError extends Error {
}
async function post<T>(path: string, body: unknown): Promise<T> {
const response = await fetch(new URL(path, getRadiusOrchestratorBaseUrl()), {
const response = await fetch(new URL(path, getRadiusServerBaseUrl()), {
method: "POST",
headers: {
Authorization: `Bearer ${getRadiusAccessToken()}`,
@@ -62,7 +62,7 @@ async function post<T>(path: string, body: unknown): Promise<T> {
}
async function maybePost(path: string, body: unknown): Promise<void> {
const response = await fetch(new URL(path, getRadiusOrchestratorBaseUrl()), {
const response = await fetch(new URL(path, getRadiusServerBaseUrl()), {
method: "POST",
headers: {
Authorization: `Bearer ${getRadiusAccessToken()}`,
@@ -108,13 +108,13 @@ export function getRadiusUrl(): string {
return process.env.PI_RADIUS_URL || DEFAULT_RADIUS_URL;
}
export function getRadiusOrchestratorBaseUrl(): string {
const explicitUrl = process.env.PI_RADIUS_ORCHESTRATOR_URL;
export function getRadiusServerBaseUrl(): string {
const explicitUrl = process.env.PI_RADIUS_SERVER_URL;
if (explicitUrl) {
return explicitUrl;
}
return new URL(DEFAULT_ORCHESTRATOR_BASE_PATH, getRadiusUrl()).toString();
return new URL(DEFAULT_SERVER_BASE_PATH, getRadiusUrl()).toString();
}
function getStoredRadiusCredential(): OAuthCredential | undefined {
@@ -307,7 +307,7 @@ export class RadiusPresence {
try {
await maybePost(`machines/${this.machine.id}/heartbeat`, {
cwd: getOrchestratorDir(),
cwd: getServerDir(),
socketPath: getSocketPath(),
});
this.machineConsecutiveNotFoundCount = 0;
@@ -144,7 +144,7 @@ export class RpcProcessInstance {
if (this.exited) {
throw new Error(`RPC process is not running. Stderr: ${this.stderrBuffer}`);
}
const id = command.id ?? `orchestrator_${++this.nextRequestId}_${randomUUID()}`;
const id = command.id ?? `server_${++this.nextRequestId}_${randomUUID()}`;
const fullCommand = { ...command, id };
return new Promise<RpcResponse>((resolve, reject) => {
this.pendingRequests.set(id, { resolve, reject });
@@ -3,7 +3,7 @@ import { dirname } from "node:path";
import { getSocketPath } from "./config.ts";
import { handleIpcRequest, openRpcStream } from "./handler.ts";
import { startIpcServer } from "./ipc/server.ts";
import { getRadiusOrchestratorBaseUrl, isRadiusEnabled, radiusPresence } from "./radius.ts";
import { getRadiusServerBaseUrl, isRadiusEnabled, radiusPresence } from "./radius.ts";
import { supervisor } from "./supervisor.ts";
export async function serve(): Promise<void> {
@@ -19,7 +19,7 @@ export async function serve(): Promise<void> {
await supervisor.recoverAfterRestart();
if (isRadiusEnabled()) {
const machine = await radiusPresence.start();
console.log(`radius integration enabled: ${socketPath} -> ${getRadiusOrchestratorBaseUrl()}`);
console.log(`radius integration enabled: ${socketPath} -> ${getRadiusServerBaseUrl()}`);
if (machine) {
console.log(`radius machine id: ${machine.id}`);
}
@@ -34,7 +34,7 @@ export async function serve(): Promise<void> {
throw error;
}
console.log(`orchestrator listening on ${socketPath}`);
console.log(`server listening on ${socketPath}`);
let shutdownPromise: Promise<void> | undefined;
const shutdown = async (exitCode: number) => {
@@ -1,11 +1,11 @@
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { getInstancesPath, getMachinePath, getOrchestratorDir } from "./config.ts";
import { getInstancesPath, getMachinePath, getServerDir } from "./config.ts";
import type { InstanceRecord, MachineRecord } from "./types.ts";
function ensureOrchestratorDir(): void {
const orchestratorDir = getOrchestratorDir();
if (!existsSync(orchestratorDir)) {
mkdirSync(orchestratorDir, { recursive: true });
function ensureServerDir(): void {
const serverDir = getServerDir();
if (!existsSync(serverDir)) {
mkdirSync(serverDir, { recursive: true });
}
}
@@ -20,7 +20,7 @@ export function loadMachine(): MachineRecord | undefined {
}
export function saveMachine(machine: MachineRecord): void {
ensureOrchestratorDir();
ensureServerDir();
writeFileSync(getMachinePath(), JSON.stringify(machine, null, 2));
}
@@ -43,7 +43,7 @@ export function loadInstances(): InstanceRecord[] {
}
export function saveInstances(instances: InstanceRecord[]): void {
ensureOrchestratorDir();
ensureServerDir();
writeFileSync(getInstancesPath(), JSON.stringify(instances, null, 2));
}
@@ -60,7 +60,7 @@ function isGetStateSuccess(
return response.success === true && response.command === "get_state" && "data" in response;
}
export class OrchestratorSupervisor {
export class ServerSupervisor {
private readonly liveInstances = new Map<string, LiveInstance>();
private setStatus(live: LiveInstance, status: InstanceStatus): void {
@@ -339,7 +339,7 @@ export class OrchestratorSupervisor {
}
}
export const supervisor = new OrchestratorSupervisor();
export const supervisor = new ServerSupervisor();
radiusPresence.setCoordinator({
getLiveInstance(instanceId) {