import type { Clock } from '../infra/clock.js';
import type { FileSystem } from '../infra/filesystem.js';
import type { ProcessSpawner } from '../infra/spawn.js';
import { type DomainError } from '../shared/errors.js';
import { type Result } from '../shared/result.js';
export interface SystemInfo {
    readonly version: string;
    readonly nodeVersion: string;
    readonly startedAt: string;
    readonly uptimeMs: number;
    readonly platform: string;
    readonly pid: number;
}
export interface EnvEntry {
    readonly key: string;
    readonly value: string;
    readonly masked: boolean;
}
export interface EnvListing {
    readonly path: string;
    readonly exists: boolean;
    readonly entries: EnvEntry[];
}
export interface EnvRaw {
    readonly path: string;
    readonly exists: boolean;
    readonly content: string;
    readonly etag: string;
}
export interface LatestVersion {
    readonly current: string;
    readonly latest: string;
    readonly upToDate: boolean;
}
export interface UpgradeResult {
    readonly ok: boolean;
    readonly output: string;
    /** v0.50.14：npm 真正装上的版本号（null 表示查不到） */
    readonly installedVersion: string | null;
    /** 用户可以复制到终端自己跑的等价命令 */
    readonly command: string;
}
/** v0.50.14：单项目真实 doctor 输出（spawn `sps doctor <proj> --json`） */
export interface DoctorCheck {
    readonly name: string;
    readonly status: 'pass' | 'warn' | 'fail' | 'info';
    readonly message: string;
}
export interface DoctorProjectResult {
    readonly project: string;
    readonly ok: boolean;
    readonly checks: DoctorCheck[];
    readonly fixes: string[];
    /** 命令 stderr/log（debug 用） */
    readonly log: string;
}
export interface SystemServiceDeps {
    readonly fs: FileSystem;
    readonly clock: Clock;
    readonly spawner: ProcessSpawner;
    readonly version: string;
    readonly startedAt: Date;
}
export declare class SystemService {
    private readonly deps;
    constructor(deps: SystemServiceDeps);
    info(): SystemInfo;
    readEnv(): Promise<Result<EnvListing, DomainError>>;
    readEnvRaw(): Promise<Result<EnvRaw, DomainError>>;
    writeEnv(content: string, etag: string | undefined): Promise<Result<{
        etag: string;
    }, DomainError>>;
    latestVersion(): Promise<Result<LatestVersion, DomainError>>;
    /**
     * 执行 npm i -g —— pipeline 在跑时拒绝以保证原子性。
     *
     * v0.50.14：返回真正装上的版本号（npm ls 验证），避免 npm 吞错误假报成功。
     */
    upgrade(): Promise<Result<UpgradeResult, DomainError>>;
    /** 读全局安装的 sps-cli 真实版本（走 ProcessSpawner.runCommand） */
    private readInstalledVersion;
    /**
     * v0.50.14：单项目 spawn `sps doctor <project> [--fix] --json`，解析 JSON 输出。
     *
     * 实现注意：`executeDoctor` 内部用 `process.exit()` 结束，不能 in-process 调，否则
     * 把 console server 也杀了。跟 pipeline stop/reset 同样走子进程隔离。
     */
    doctorProject(project: string, opts?: {
        fix?: boolean;
    }): Promise<Result<DoctorProjectResult, DomainError>>;
    /** 列出当前在跑 pipeline 的项目名 —— upgrade 前置检查用 */
    private listRunningPipelines;
}
//# sourceMappingURL=SystemService.d.ts.map