UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

58 lines (57 loc) • 3.14 kB
import { B as timestampMsToIsoFileStamp } from "./number-coercion-D6u-4YD8.mjs"; import { t as escapeRegExp } from "./regexp-dj3rRPbj.mjs"; import { a as isTrajectoryRuntimeArtifactName, n as hasArchiveSuffix, o as parseUsageCountedSessionIdFromFileName, s as readSessionArchiveTimestamp } from "./transcript-file-names-mCC_xfFb.mjs"; //#region src/config/sessions/artifacts.ts const LEGACY_STORE_BACKUP_RE = /^sessions\.json\.bak\.\d+$/; const PRE_DOCTOR_REPAIR_RE = /\.jsonl\.pre-doctor-(?:branch|openai-codex)-repair-\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z\.bak$/u; const MIGRATION_ARCHIVE_RE = /\.migrated(?:\.\d+)?$/u; /** Returns true for archived session artifacts and legacy store backup names. */ function isSessionArchiveArtifactName(e) { return LEGACY_STORE_BACKUP_RE.test(e) || isRetainedSessionTranscriptArchiveName(e); } /** Returns true for retained archives and disposable legacy compact backups pruned at high water. */ function isRetainedSessionTranscriptArchiveName(e) { return hasArchiveSuffix(e, "deleted") || hasArchiveSuffix(e, "reset") || hasArchiveSuffix(e, "bak"); } /** Returns true for migration rollback archives retained beside their legacy source. */ function isMigrationArchiveArtifactName(e) { return MIGRATION_ARCHIVE_RE.test(e) || PRE_DOCTOR_REPAIR_RE.test(e); } const SESSION_STORE_TEMP_RE_CACHE = /* @__PURE__ */ new Map(); const SESSION_STORE_TEMP_STALE_MS = 3e5; function sessionStoreTempPattern(e) { let t = SESSION_STORE_TEMP_RE_CACHE.get(e); if (!t) { t = new RegExp(`^${escapeRegExp(e)}\\.(?:\\d+\\.)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\.tmp$`, "i"); SESSION_STORE_TEMP_RE_CACHE.set(e, t); } return t; } function isSessionStoreTempArtifactName(e, t) { if (!t) return false; return sessionStoreTempPattern(t).test(e); } function resolveTrajectoryPath(e) { return e.endsWith(".jsonl") ? `${e.slice(0, -6)}.trajectory.jsonl` : void 0; } function resolveTrajectoryPointerPath(e) { return e.endsWith(".jsonl") ? `${e.slice(0, -6)}.trajectory-path.json` : void 0; } function isTrajectorySessionArtifactName(e) { return isTrajectoryRuntimeArtifactName(e) || e.endsWith(".trajectory-path.json"); } /** Returns true for transcript files counted in usage, including reset/deleted archives. */ function isUsageCountedSessionTranscriptFileName(e) { return parseUsageCountedSessionIdFromFileName(e) !== null; } function formatSessionArchiveTimestamp(e = Date.now()) { return timestampMsToIsoFileStamp(e); } function parseSessionArchiveTimestamp(e, t) { const n = readSessionArchiveTimestamp(e, t); if (!n) return null; const r = Date.parse(n.slice(0, 11) + n.slice(11).replace(/-/g, ":")); return Number.isNaN(r) ? null : r; } //#endregion export { isSessionArchiveArtifactName as a, isUsageCountedSessionTranscriptFileName as c, resolveTrajectoryPointerPath as d, isRetainedSessionTranscriptArchiveName as i, parseSessionArchiveTimestamp as l, formatSessionArchiveTimestamp as n, isSessionStoreTempArtifactName as o, isMigrationArchiveArtifactName as r, isTrajectorySessionArtifactName as s, SESSION_STORE_TEMP_STALE_MS as t, resolveTrajectoryPath as u };