export interface ProfileAccount { readonly userId: string readonly tenantId: string readonly displayName: string | null readonly avatarUrl: string | null } export interface ProfileSnapshot { readonly schemaVersion: 1 readonly user: { readonly userId: string | null; readonly tenantId: string | null; readonly displayName: string | null; readonly avatarUrl: string | null } readonly serverUrl: string | null readonly account: ProfileAccount | null readonly device: { readonly id: string; readonly name: string | null; readonly binding: 'ready' | 'missing' } | null readonly identityRevision: string | null } export interface ProfileWriterBlocker { readonly kind: 'app-process' | 'cli-process' | 'codem-process' | 'session-handle' readonly processId: number | null readonly processName: string | null } export type ProfileSetupChoice = { readonly kind: 'migrate'; readonly home: string } | { readonly kind: 'new' | 'defer' | 'resume' } export interface ProfileSetupSnapshot { readonly stage: 'choice' | 'welcome' | 'working' | 'blocked' readonly situation: 'accounts' | 'devices' | 'recovery' | 'desktop-data' readonly targetHome: string readonly environment: string readonly backupHome: string readonly profiles: { readonly home: string readonly accountKey: string | null readonly accountLabel: string readonly deviceId: string | null readonly status: 'available' | 'signed-out' | 'recovery' | 'other-environment' readonly issue: string | null }[] readonly recommendedHome: string readonly busy: boolean readonly blockers: ProfileWriterBlocker[] readonly notice: string | null readonly diagnosticId: string | null } export interface ProfileMigrationOptions { readonly mode: 'automatic' | 'maintenance' readonly targetHome: string readonly legacyHomes: readonly string[] readonly backupHome: string readonly serverOrigin: string readonly migrateSessions: (sessionRoots: readonly string[]) => Promise readonly choose: (snapshot: ProfileSetupSnapshot) => Promise } export type ProfileMigrationResult = { readonly kind: 'ready'; readonly backupHome: string | null; readonly legacyCleanupPending: boolean } | { readonly kind: 'defer' } export class CodeMProfileMigrationError extends Error {} export class CodeMProfileMigrationBlockedError extends CodeMProfileMigrationError { readonly code: 'CODEM_PROFILE_MIGRATION_BLOCKED' readonly reason: 'daemon-active' | 'session-writer-active' | 'writer-inspection-failed' readonly blockers: readonly ProfileWriterBlocker[] constructor(detail: string, reason: CodeMProfileMigrationBlockedError['reason'], blockers: readonly ProfileWriterBlocker[], options?: ErrorOptions) } export function readProfileSnapshot(home: string): Promise export function canonicalCodeMProfileHome(home: string): Promise export function migrateCodeMProfile(options: ProfileMigrationOptions): Promise export function withProfileSessionMaintenance(home: string, operation: () => Promise): Promise