/**
 * @module        services/WorkerService
 * @description   Worker 查询 + 控制 service
 *
 * @layer         services
 *
 * 职责：
 *   - 读 runtime/worker-worker-<N>-current.json marker → 结构化 WorkerInfo
 *   - 列项目 workers / 跨项目聚合
 *   - launch / kill —— Phase 2 暂不负责真 spawn，返 pending port（Phase 3 填）
 *
 * 不负责：
 *   - marker 写入（worker-manager 的事）
 *   - 日志 tail（LogService）
 */
import type { Clock } from '../infra/clock.js';
import type { FileSystem } from '../infra/filesystem.js';
import type { DomainEventBus } from '../shared/domainEvents.js';
import { type DomainError } from '../shared/errors.js';
import { type Result } from '../shared/result.js';
export type WorkerState = 'idle' | 'starting' | 'running' | 'stuck' | 'crashed';
export interface WorkerInfo {
    readonly slot: number;
    readonly pid: number | null;
    readonly state: WorkerState;
    readonly card: {
        seq: number;
        title: string;
    } | null;
    readonly stage: string | null;
    readonly startedAt: string | null;
    readonly runtimeMs: number | null;
    readonly markerUpdatedAt: string | null;
}
export interface AggregateResult {
    readonly alerts: Array<WorkerInfo & {
        project: string;
    }>;
    readonly active: Array<WorkerInfo & {
        project: string;
    }>;
    readonly capacity: Array<{
        project: string;
        total: number;
        running: number;
        starting: number;
        stuck: number;
        crashed: number;
        idle: number;
    }>;
}
/** Service 让调用方注入 launch/kill 执行器（Phase 3 由 CLI 命令绑定） */
export interface WorkerExecutor {
    launch(project: string, seq: number): Promise<void>;
    kill(project: string, slot: number): Promise<void>;
}
export interface WorkerServiceDeps {
    readonly fs: FileSystem;
    readonly clock: Clock;
    readonly events: DomainEventBus;
    /** 卡片 title 反查器（CardService 实例或类似），Phase 3 注入。不注入则 title 用 `#<seq>`。 */
    readonly cardTitleLookup?: (project: string, seq: number) => Promise<string | null>;
    readonly executor?: WorkerExecutor;
}
export declare class WorkerService {
    private readonly deps;
    constructor(deps: WorkerServiceDeps);
    /** 列单项目的 worker slots（按 slot 数字升序）。 */
    listByProject(project: string): Promise<Result<WorkerInfo[], DomainError>>;
    /** 单 slot detail。 */
    getBySlot(project: string, slot: number): Promise<Result<WorkerInfo, DomainError>>;
    /** 跨项目聚合 —— Workers 页用。 */
    aggregate(): Promise<Result<AggregateResult, DomainError>>;
    /** launch 转发到注入的 executor。未注入返 internal。 */
    launch(project: string, seq: number): Promise<Result<void>>;
    kill(project: string, slot: number): Promise<Result<void>>;
    /** 扫 runtime/ 下 marker 文件，匹配双前缀 + 单前缀，返 slot 数字 + 实际路径 */
    private listMarkerSlots;
    /** 优先双前缀，再试老单前缀 */
    private resolveMarkerPath;
    private buildInfo;
}
//# sourceMappingURL=WorkerService.d.ts.map