Extract Ralph loop lifecycle management: - loop-state-controller.ts: start/stop/recovery state machine - ralph-loop-event-handler.ts: event handling logic - continuation-prompt-builder.ts, continuation-prompt-injector.ts - completion-promise-detector.ts, loop-session-recovery.ts - message-storage-directory.ts
17 lines
549 B
TypeScript
17 lines
549 B
TypeScript
import { existsSync, readdirSync } from "node:fs"
|
|
import { join } from "node:path"
|
|
import { MESSAGE_STORAGE } from "../../features/hook-message-injector"
|
|
|
|
export function getMessageDir(sessionID: string): string | null {
|
|
if (!existsSync(MESSAGE_STORAGE)) return null
|
|
|
|
const directPath = join(MESSAGE_STORAGE, sessionID)
|
|
if (existsSync(directPath)) return directPath
|
|
|
|
for (const dir of readdirSync(MESSAGE_STORAGE)) {
|
|
const sessionPath = join(MESSAGE_STORAGE, dir, sessionID)
|
|
if (existsSync(sessionPath)) return sessionPath
|
|
}
|
|
return null
|
|
}
|