UNPKG

@code-yeongyu/senpi

Version:

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

36 lines • 1.56 kB
import { parseJson } from "./host-daemon-state.js"; import { processStartTimeIsUnreadable } from "./host-stop-start-time.js"; export function parseHostStopGeneration(text) { const value = parseJson(text); if (!value || typeof value.instanceId !== "string" || value.instanceId.length === 0 || typeof value.generation !== "number" || !Number.isSafeInteger(value.generation) || value.generation < 0 || typeof value.pid !== "number" || !Number.isSafeInteger(value.pid) || value.pid <= 0 || !(value.processStartTime === null || (typeof value.processStartTime === "string" && value.processStartTime.length > 0))) return undefined; return { instanceId: value.instanceId, generation: value.generation, pid: value.pid, processStartTime: value.processStartTime, }; } export function compareStopGeneration(registered, expected) { if (registered?.instanceId !== expected.instanceId || registered.generation !== expected.generation || registered.record.pid !== expected.pid) return "stale"; const recorded = registered.record.processStartTime; if (recorded !== null && expected.processStartTime !== null) return recorded === expected.processStartTime ? "proven" : "stale"; if (recorded === null && expected.processStartTime === null && processStartTimeIsUnreadable()) return "bound_without_start_time"; return "unprovable"; } //# sourceMappingURL=host-stop-generation.js.map