/** Compatibility facade over the authoritative Workspace Index. */ import { workspaceIndexService } from './workspaceIndex.js'; export interface RecentDirEntry { path: string; name: string; lastUsedAt: number; title?: string; /** Legacy v1 hint. It is never used as an existence check. */ sessionFile?: string; available?: boolean; workspaceId?: string; } function asRecent(workspace: Awaited>[number]): RecentDirEntry { const latest = [...workspace.sessions].sort((a, b) => b.updatedAt - a.updatedAt)[0]; return { path: workspace.displayPath, name: workspace.displayName, lastUsedAt: workspace.lastActiveAt, ...(latest?.title ? { title: latest.title } : {}), available: workspace.available, workspaceId: workspace.id, }; } export async function listRecentDirs(): Promise { return (await workspaceIndexService.list()).map(asRecent); } export async function upsertRecentDir(cwd: string, title?: string): Promise { return asRecent(await workspaceIndexService.register(cwd, title)); } /** Best-effort CLI hook: index failure must not fail an Agent turn. */ export async function recordRecentDir(cwd: string, title?: string): Promise { await workspaceIndexService.register(cwd, title).then(() => undefined, () => undefined); } export async function removeRecentDir(cwd: string): Promise { await workspaceIndexService.removeWorkspace(cwd); }