import "./openclaw-runtime-B4gMnFSp.js";
import path from "node:path";
//#region packages/memory-host-sdk/src/host/openclaw-runtime-session.ts
/** Extracts the agent id from a canonical `agents/<id>/sessions` directory path. */
function extractAgentIdFromSessionsDir(sessionsDir) {
	const parts = path.normalize(path.resolve(sessionsDir)).split(path.sep).filter(Boolean);
	const sessionsIndex = parts.length - 1;
	if (parts[sessionsIndex] !== "sessions" || sessionsIndex < 2 || parts[sessionsIndex - 2] !== "agents") return null;
	return parts[sessionsIndex - 1] || null;
}
/** Session-key prefix marking transcripts generated by memory dreaming runs. */
const DREAMING_NARRATIVE_RUN_PREFIX = "dreaming-narrative-";
/** True when a session-store key belongs to a dreaming narrative run. */
function isDreamingNarrativeSessionStoreKey(sessionKey) {
	const trimmed = sessionKey.trim();
	if (!trimmed) return false;
	const firstSeparator = trimmed.indexOf(":");
	if (firstSeparator < 0) return trimmed.startsWith(DREAMING_NARRATIVE_RUN_PREFIX);
	const secondSeparator = trimmed.indexOf(":", firstSeparator + 1);
	return (secondSeparator < 0 ? trimmed : trimmed.slice(secondSeparator + 1)).startsWith(DREAMING_NARRATIVE_RUN_PREFIX);
}
//#endregion
export { extractAgentIdFromSessionsDir as n, isDreamingNarrativeSessionStoreKey as r, DREAMING_NARRATIVE_RUN_PREFIX as t };
