mirror of
https://github.com/stablyai/orca.git
synced 2026-10-24 08:03:58 +00:00
Splits the nine oversized modules in the daemon/provider/runtime domain into focused per-concern files and drops their max-lines baseline entries. - daemon: `Session` decomposes into an output plane (emulator, pending-output buffer, client fan-out), a producer-pause controller, a shell-ready barrier and a termination controller; `DaemonClient` into socket connect, hello handshake, ndjson readers, pending-request settlement, listener registry and notify settlement; `daemon-health` into pid-file parsing, process identity, stale-kill, TCC attribution and bundle staleness; `shell-ready` into the marker constant and the bash/zsh rcfile generators. - providers: local-pty shell-ready wrapper generation, wrapper root, startup command and bash rcfile split out of local-pty-shell-ready. - runtime: `Coordinator` sheds DAG convergence, decision gates, escalation triage, the runtime contract, the stale-base flag and task dispatch; the files/git/github rpc modules split into per-domain method groups. Behavior-preserving: the extracted units keep their original construction order, guards and timer lifetimes, and every RPC method name is still registered. Test `vi.mock` surfaces were re-partitioned to follow the moved symbols.
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
export type ParsedDaemonPid = {
|
|
pid: number
|
|
startedAtMs: number | null
|
|
entryPath: string | null
|
|
appVersion: string | null
|
|
launchNonce: string | null
|
|
linuxStartTicks: string | null
|
|
bootId: string | null
|
|
spawnerExecPath: string | null
|
|
}
|
|
|
|
export function parseDaemonPidFile(contents: string): ParsedDaemonPid | null {
|
|
const trimmed = contents.trim()
|
|
try {
|
|
const parsed = JSON.parse(trimmed) as {
|
|
pid?: unknown
|
|
startedAtMs?: unknown
|
|
entryPath?: unknown
|
|
appVersion?: unknown
|
|
launchNonce?: unknown
|
|
linuxStartTicks?: unknown
|
|
bootId?: unknown
|
|
spawnerExecPath?: unknown
|
|
}
|
|
if (typeof parsed.pid === 'number' && Number.isFinite(parsed.pid)) {
|
|
return {
|
|
pid: parsed.pid,
|
|
startedAtMs:
|
|
typeof parsed.startedAtMs === 'number' && Number.isFinite(parsed.startedAtMs)
|
|
? parsed.startedAtMs
|
|
: null,
|
|
entryPath: typeof parsed.entryPath === 'string' ? parsed.entryPath : null,
|
|
appVersion: typeof parsed.appVersion === 'string' ? parsed.appVersion : null,
|
|
launchNonce: typeof parsed.launchNonce === 'string' ? parsed.launchNonce : null,
|
|
linuxStartTicks: typeof parsed.linuxStartTicks === 'string' ? parsed.linuxStartTicks : null,
|
|
bootId: typeof parsed.bootId === 'string' ? parsed.bootId : null,
|
|
spawnerExecPath: typeof parsed.spawnerExecPath === 'string' ? parsed.spawnerExecPath : null
|
|
}
|
|
}
|
|
} catch {
|
|
// Legacy daemons wrote the pid file as a bare integer.
|
|
}
|
|
|
|
const pid = Number(trimmed)
|
|
return Number.isFinite(pid)
|
|
? {
|
|
pid,
|
|
startedAtMs: null,
|
|
entryPath: null,
|
|
appVersion: null,
|
|
launchNonce: null,
|
|
linuxStartTicks: null,
|
|
bootId: null,
|
|
spawnerExecPath: null
|
|
}
|
|
: null
|
|
}
|