()
| 64 | // owns and that have been idle past the retention threshold. Never touches the |
| 65 | // global ~/.agent-device root contents. |
| 66 | function pruneStaleDevStateDirs(): void { |
| 67 | const devRoot = path.join(os.homedir(), '.agent-device', 'dev'); |
| 68 | const cutoffMs = Date.now() - PRUNE_DEV_MAX_AGE_MS; |
| 69 | for (const dirPath of listDevStateDirs(devRoot)) { |
| 70 | if (hasLiveDaemon(dirPath) || newestMtimeMs(dirPath) > cutoffMs) continue; |
| 71 | fs.rmSync(dirPath, { recursive: true, force: true }); |
| 72 | process.stdout.write(`Removed stale daemon state dir: ${dirPath}\n`); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | function listDevStateDirs(devRoot: string): string[] { |
| 77 | let entries: fs.Dirent[]; |
no test coverage detected