@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
79 lines • 5.11 kB
TypeScript
export { canonicalEndpointPath, daemonDirectoryName, parseShardSocket, type ShardKind, sameEndpoint, shardKey, shardSocketPath, shardSocketPathForKey, socketNamesDirectory, } from "./host-endpoint-names.ts";
export { createGenerationDirectory, generationPaths, HostDaemonStateError, type HostGenerationPaths, } from "./host-generation-paths.ts";
/** The layout this build writes. A directory without the marker predates it and is never touched. */
export declare const HOST_DAEMON_LAYOUT = 2;
/** Absolute daemon directory handed to a spawned host, which binds a private socket of its own. */
export declare const HOST_DAEMON_DIR_ENV = "SENPI_RPC_HOST_DAEMON_DIR";
/** The `endpoint.json` schema this build writes; readers accept any record that names its socket. */
export declare const ENDPOINT_REGISTRY_VERSION = 1;
/** What serves an endpoint: a multi-session RPC host, or an interactive terminal's control endpoint. */
export type EndpointKind = "rpc_host" | "tui";
export declare const HOST_STATE_FILE_MODE = 384;
export interface HostDaemonPaths {
/** The endpoint these paths belong to, exactly as its directory name was derived from. */
readonly socket: string;
/** `<agentDir>/rpc-host-daemon`: shared by every endpoint, and by any legacy host's own state. */
readonly flatDir: string;
/** The only file this build writes into the flat directory: `{ layout, dir }`. */
readonly layoutMarker: string;
/** A LEGACY host's registration. Read-only evidence that another host may be running. */
readonly legacyPidFile: string;
/** This endpoint's state directory, `<flatDir>/<sha256(canonical socket)[:16]>`. */
readonly dir: string;
/** Durable identity `{ layout, registry_version, endpoint_kind, socket, created_at }`: survives every generation's release. */
readonly endpointFile: string;
/** The pointer at the current generation. Deliberately unparseable as a legacy pidfile. */
readonly pointerFile: string;
/** Cross-version ensure lock for this endpoint (the endpoint lock itself lives in the temp dir). */
readonly lockFile: string;
readonly settingsFile: string;
readonly stderrLog: string;
readonly generationsDir: string;
readonly reservationsDir: string;
}
/** The files inside one endpoint's directory, for a reader that has the directory but not its socket. */
export type HostDaemonDirectory = Omit<HostDaemonPaths, "socket" | "flatDir" | "layoutMarker" | "legacyPidFile">;
/**
* The daemon directory of ONE endpoint. Both fields are named rather than positional on purpose:
* two strings in a row is exactly the call a refactor silently swaps, and swapping these two would
* point a client at another socket's state.
*/
export declare function createHostDaemonPaths(target: {
readonly socket: string;
readonly agentDir?: string;
}): HostDaemonPaths;
/**
* The files inside one endpoint's directory, for a caller that was TOLD the directory instead of
* the socket it serves - a supervised host binds a private hop, so it cannot derive the endpoint.
* The names live here alone, so the directory a client recomputes and the one a host is handed
* can never drift apart.
*/
export declare function hostDaemonDirectoryPaths(dir: string): HostDaemonDirectory;
/**
* Creates this endpoint's directories and publishes the flat marker. A directory that already exists
* keeps whatever mode it was created with - and this one holds the evidence that decides who may
* signal the daemon - so an existing one is re-moded explicitly; one `mkdir` just created already
* has the mode. The siblings inside the endpoint directory and the marker are written concurrently.
* A `tui` registrant passes its kind; everything else is an `rpc_host`.
*/
export declare function createDaemonDirectories(paths: HostDaemonPaths, identity?: {
readonly kind?: EndpointKind;
}): Promise<void>;
/**
* Writes `endpoint.json` when it is absent and never rewrites a valid one: the first writer's
* `created_at` is the endpoint's birth. The file is written whole to a temporary name and LINKED
* into place, so a reader never sees it half-written and a second writer racing the first loses on
* the link rather than replacing it. `repair` - asserted only by an ensure under this socket's ensure
* lock, where `gc` cannot be deciding about the directory - also replaces a file that does not name a
* socket of this directory (torn by a crash of an older build, or foreign), which would otherwise
* leave the endpoint unaddressable, and never `gc`-able, for good.
*
* A filesystem without hard links (exFAT/FAT, some network and FUSE mounts: `link()` fails with
* ENOTSUP, EPERM, ENOSYS...) gets the exclusive create of the final file instead. That write is not
* atomic, but the first writer still wins, and a file torn by a crash is exactly what `repair` rewrites.
*/
export declare function ensureEndpointIdentity(paths: HostDaemonPaths, socket: string, options?: {
readonly repair?: boolean;
readonly kind?: EndpointKind;
}): Promise<void>;
//# sourceMappingURL=host-daemon-paths.d.ts.map