import fs from "node:fs/promises";
//#region src/agent/embedded/session-manager-cache.ts
const DEFAULT_TTL_MS = 3e4;
/**
* Tracks which session JSONL files we have already confirmed exist on disk so
* subsequent acquires can skip the open/close probe. The class is owned by the
* session runner pool; {@link defaultSessionManagerCache} keeps the free-function
* API working until every caller has been wired through dependency injection.
*/
var SessionManagerCache = class {
	seen = /* @__PURE__ */ new Map();
	async prewarm(sessionFile) {
		if (this.seen.get(sessionFile) === true) return;
		try {
			await (await fs.open(sessionFile, "r")).close();
			this.seen.set(sessionFile, true);
		} catch {}
	}
	trackAccess(sessionFile) {
		this.seen.set(sessionFile, true);
	}
	has(sessionFile) {
		return this.seen.get(sessionFile) === true;
	}
	resetForTest() {
		this.seen.clear();
	}
};
const defaultSessionManagerCache = new SessionManagerCache();
function prewarmSessionFile(sessionFile) {
	return defaultSessionManagerCache.prewarm(sessionFile);
}
function trackSessionManagerAccess(sessionFile) {
	defaultSessionManagerCache.trackAccess(sessionFile);
}
function isSessionManagerCached(sessionFile) {
	return defaultSessionManagerCache.has(sessionFile);
}
function resetSessionManagerCacheForTest() {
	defaultSessionManagerCache.resetForTest();
}
function getSessionManagerCacheTtlMs() {
	return DEFAULT_TTL_MS;
}
//#endregion
export { SessionManagerCache, defaultSessionManagerCache, getSessionManagerCacheTtlMs, isSessionManagerCached, prewarmSessionFile, resetSessionManagerCacheForTest, trackSessionManagerAccess };

//# sourceMappingURL=session-manager-cache.js.map