UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

37 lines (36 loc) • 2.39 kB
import { type PeerDirectory, type PeerRegistryDirectoryRefusal } from "./peer-directory.js"; /** The reference's label for a session that has no name (its listing prints it; a peer is addressed by it). */ export declare const CC_UNNAMED_SESSION_NAME = "(unnamed session)"; /** What the liveness judgment asks the operating system. Injectable: a test never spawns `ps`. */ export interface CcProcessProbe { /** Does a process with this pid exist (signal 0; a process this uid may not signal still exists)? */ processExists(pid: number): boolean; /** The process start token the reference writes and compares, or `undefined` when it cannot be read * (the reference then takes the pid's word). */ processStartToken(pid: number): Promise<string | undefined>; } /** The reference's start token: `ps -o lstart= -p <pid>` under `LC_ALL=C TZ=UTC`, trimmed. An OPAQUE token the * reference compares for equality — never parsed into a time (the engine's own lock probe asks `etime` for that). */ export declare function ccProcessStartToken(pid: number): Promise<string | undefined>; export declare const defaultCcProcessProbe: CcProcessProbe; /** Why one registry file was not read into the listing (closed set; reported, never thrown). */ export type CcPeerRowSkip = "not_regular" | "foreign_owner" | "group_or_world_writable" | "too_large" | "unreadable" | "not_json" | "no_socket" | "not_live" | "invalid_row"; /** The registry directory failed its vetting: the listing refuses instead of answering empty. */ export declare class CcPeerDirectoryError extends Error { readonly code: PeerRegistryDirectoryRefusal; readonly path: string; constructor(code: PeerRegistryDirectoryRefusal, path: string); } export interface CcPeerDirectoryOptions { /** The reference's registry directory (`ccPeerDefaultLocations().registryDir`). */ registryDir: string; /** The scope every row of this registry belongs to (the reference is single-user). Default {@link ANONYMOUS_SCOPE}. */ scope?: string; probe?: CcProcessProbe; /** One call per skipped file. */ onSkip?: (file: string, reason: CcPeerRowSkip, detail?: string) => void; /** Tests: the uid / platform the vetting and the file judgment use. */ uid?: number; platform?: NodeJS.Platform; } export declare function createCcPeerDirectory(opts: CcPeerDirectoryOptions): PeerDirectory;