import { promises as fs } from 'node:fs'; export type WorkspaceMaterializationMode = 'worktree' | 'symlink'; export type WorkspaceSessionStatus = 'running' | 'stopped'; export type WorkspaceStatus = 'active' | 'idle' | 'archived' | 'cleaned' | 'missing'; export interface WorkspaceSessionRepoContext { readonly alias: string; readonly sourcePath: string; readonly targetPath: string; readonly mode: WorkspaceMaterializationMode; readonly gitRoot: string | null; readonly branch: string | null; readonly head: string | null; } export interface WorkspaceSessionContext { readonly workspaceId: string; readonly workspaceName: string; readonly workspaceRootPath: string; readonly workspaceDefaultCwd: string; readonly workspaceMode: WorkspaceMaterializationMode; readonly currentPath?: string; readonly repo?: WorkspaceSessionRepoContext; } export interface WorkspaceRepoInput { readonly path: string; readonly alias?: string; readonly mode?: WorkspaceMaterializationMode; } export interface WorkspaceCreateInput { readonly name: string; readonly repos: readonly WorkspaceRepoInput[]; readonly mode?: WorkspaceMaterializationMode; readonly branchName?: string; readonly rootDir?: string; } export interface WorkspaceSessionBinding { readonly agent: string; readonly sessionId: string; readonly status: WorkspaceSessionStatus; readonly cwd?: string; readonly title?: string; readonly updatedAt: string; readonly activeRunId?: string | null; readonly latestRunId?: string | null; } export interface WorkspaceRepoRecord { readonly alias: string; readonly sourcePath: string; readonly targetPath: string; readonly mode: WorkspaceMaterializationMode; readonly gitRoot: string | null; readonly branch: string | null; readonly head: string | null; } export interface WorkspaceRecord { readonly id: string; readonly name: string; readonly rootPath: string; readonly mode: WorkspaceMaterializationMode; readonly createdAt: string; readonly archivedAt: string | null; readonly cleanedAt: string | null; readonly repos: readonly WorkspaceRepoRecord[]; readonly sessions: readonly WorkspaceSessionBinding[]; } export interface WorkspaceRepoSummary extends WorkspaceRepoRecord { readonly exists: boolean; } export interface WorkspaceActionAvailability { readonly canArchive: boolean; readonly canCleanup: boolean; readonly canDelete: boolean; readonly canRecover: boolean; } export interface WorkspaceSummary { readonly id: string; readonly name: string; readonly rootPath: string; readonly defaultCwd: string; readonly mode: WorkspaceMaterializationMode; readonly status: WorkspaceStatus; readonly createdAt: string; readonly archivedAt: string | null; readonly cleanedAt: string | null; readonly repos: readonly WorkspaceRepoSummary[]; readonly sessions: readonly WorkspaceSessionBinding[]; readonly actions: WorkspaceActionAvailability; } export interface WorkspaceListResult { readonly workspaces: readonly WorkspaceSummary[]; readonly summary: { readonly total: number; readonly active: number; readonly idle: number; readonly archived: number; readonly cleaned: number; readonly missing: number; }; } export interface WorkspaceServiceDeps { readonly readFile: typeof fs.readFile; readonly writeFile: typeof fs.writeFile; readonly mkdir: typeof fs.mkdir; readonly rm: typeof fs.rm; readonly symlink: typeof fs.symlink; readonly unlink: typeof fs.unlink; readonly stat: typeof fs.stat; readonly lstat: typeof fs.lstat; readonly readdir: typeof fs.readdir; readonly execGit: (args: string[], cwd: string) => Promise<{ stdout: string; stderr: string; }>; readonly now: () => string; readonly homedir: () => string; } export declare function resolveWorkspaceDefaultCwd(workspace: Pick | Pick): string; export declare class WorkspaceService { private readonly deps; constructor(deps?: Partial); rootDir(): string; listWorkspaces(options?: { readonly liveSessions?: readonly WorkspaceSessionBinding[]; }): Promise; createWorkspace(input: WorkspaceCreateInput): Promise; archiveWorkspace(identifier: string): Promise; cleanupWorkspace(identifier: string): Promise; recoverWorkspace(identifier: string): Promise; deleteWorkspace(identifier: string, options?: { readonly forceCleanup?: boolean; }): Promise; bindSession(input: { readonly workspaceId: string; readonly session: WorkspaceSessionBinding; }): Promise; reconcileSessions(liveSessions: readonly WorkspaceSessionBinding[]): Promise; resolveWorkspace(identifier: string): Promise; resolveSessionContext(input: { readonly workspaceId?: string; readonly cwd?: string; }): Promise; resolveWorkspaceCwd(workspace: Pick | Pick): string; }