UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

114 lines • 6.07 kB
import type { NativePublishResult } from "./socket-secret-publish.ts"; export type { LeftBehindStaging, NativeLeftBehindStaging, NativePublishResult, SocketSecretPublication, } from "./socket-secret-publish.ts"; export { publishSocketSecretNoReplace, SocketSecretPublishError } from "./socket-secret-publish.ts"; export interface NativeKernelSessionIdentity { readonly status: "verified" | "unverified"; readonly creationTime: string | null; readonly reason: string | null; } export interface NativeVolumeLocality { readonly locality: "local" | "not_local"; readonly reason: string | null; readonly reportedFileSystem: string | null; } export interface NativeSocketSecretBinding { __senpiSocketSecretAbi1(): string; publishNoReplace(stagingPath: string, finalPath: string, bytes: Buffer): NativePublishResult; kernelSessionIdentity(): NativeKernelSessionIdentity; classifyVolume(path: string): NativeVolumeLocality; } /** * A successful probe is retained native release evidence, never a transient "free" hint. A blocking wait's `acquired` * is NOT yet evidence: that handle becomes evidence only once `probeRetained` applies the admissibility rules to it * (design Revision 8, r7 note 4), inside the recovery transaction. */ export type NativePresenceResult = { readonly status: "acquired" | "occupied" | "valid" | "released" | "cancelled"; } | { readonly status: "unknown" | "fenced"; readonly reason: string; readonly code?: number | null; } | { readonly status: "unavailable"; readonly reason: "unsupported_platform"; }; export interface NativePresenceProbe { readonly presenceId: string; readonly path: string; /** * The object's whole immutable header as the row recorded it (design 4.2a: random tag, schema, creation timestamp). * The bridge compares the opened object with it byte for byte; the tag alone never matches. */ readonly header: Buffer; readonly volumeSerial: string; readonly fileId: string; readonly createdLocal: boolean; readonly relocated: boolean; readonly kernelSession: string | null; } /** * Why a guard leaves the registry (design 4.2a recovery transaction order). `released` is the holder's own quiescence * commit; the other three are the points at which recovery releases guards it recovered: `recovery_abandoned` when step 3 * meets contention or an error and the attempt cannot retire, `discharged` when step 4 finds the role committed * `released` meanwhile, `retired` after step 5's retirement commit and object deletion. Nothing else releases a guard. */ export type PresenceReleaseReason = "released" | "recovery_abandoned" | "discharged" | "retired"; /** The caller commits the state named by `state` (terminal, drained, or the recovery step) before supplying this receipt. */ export interface PresenceReleasedReceipt { readonly presenceId: string; readonly state: PresenceReleaseReason; } export interface NativePresenceBinding { presenceAcquire(presenceId: string, path: string): NativePresenceResult; presenceProbe(request: NativePresenceProbe): NativePresenceResult; /** * The probe's admissibility rules applied to a guard this process already retains, the one a blocking wait acquired * (design Revision 8, r7 note 4): `acquired` keeps it, an inadmissible handle is released at once (`unknown`, * `inadmissible`), and a guard not held is `unknown` (`not_held`). The handle is never closed and reacquired. */ presenceProbeRetained(request: NativePresenceProbe): NativePresenceResult; presencePreActionCheck(presenceId: string): NativePresenceResult; presenceWaitAndAcquire(presenceId: string, path: string, waitId: string): Promise<NativePresenceResult>; presenceCancelWait(waitId: string): void; presenceReleaseAfterQuiescence(receipt: PresenceReleasedReceipt): NativePresenceResult; } export interface SocketSecretPresence { acquire(presenceId: string, path: string): NativePresenceResult; probe(request: NativePresenceProbe): NativePresenceResult; /** Step 3's admissibility check for the guard `waitAndAcquire` retained; see `presenceProbeRetained`. */ probeRetained(request: NativePresenceProbe): NativePresenceResult; preActionCheck(presenceId: string): NativePresenceResult; waitAndAcquire(presenceId: string, path: string, signal?: AbortSignal): Promise<NativePresenceResult>; releaseAfterQuiescence(receipt: PresenceReleasedReceipt): NativePresenceResult; } /** POSIX endpoints have no public-secret presence contract. Do not load a Windows bridge there. */ export declare function loadSocketSecretPresence(options?: SocketSecretNativeOptions, native?: NativePresenceBinding): { readonly status: "available"; readonly guard: SocketSecretPresence; } | { readonly status: "unavailable"; readonly reason: "unsupported_platform"; }; export interface SocketSecretNativeOptions { readonly packageDir?: string; readonly moduleDir?: string; readonly execPath?: string; readonly env?: NodeJS.ProcessEnv; readonly platform?: string; readonly arch?: string; readonly requireBinding?: (modulePath: string) => unknown; } export declare class SocketSecretNativeUnavailableError extends Error { readonly code = "socket-secret-native-unavailable"; readonly attemptedPaths: readonly string[]; constructor(host: string, attemptedPaths: readonly string[], causes: readonly string[]); } export declare class SocketSecretNativeAbiMismatchError extends Error { readonly code = "socket-secret-native-abi-mismatch"; readonly modulePath: string; constructor(modulePath: string); } export declare function socketSecretNativeCandidatePaths(options?: SocketSecretNativeOptions): readonly string[]; /** Loads the bridge or throws; a sentinel mismatch stops at once instead of trying the next candidate. */ export declare function loadSocketSecretNative(options?: SocketSecretNativeOptions): NativeSocketSecretBinding; //# sourceMappingURL=socket-secret-native.d.ts.map