/** * PipelineOrchestrator — 可扩展管线编排器 * FR-K01 * * 管线由有序阶段组成,每个阶段独立执行、独立可跳过。 * 新增处理阶段只需注册到管线,不修改已有阶段逻辑。 * * 默认阶段顺序: * extraction → analysis_artifact → classification → conflict_detection → merge_detection → persistence */ import type { KnowledgeEntry, KnowledgeSource, PipelineStage } from '../types/index.js'; import { EventBus } from './event-bus.js'; /** 管线阶段执行上下文 */ export interface StageContext { taskId: string; source: KnowledgeSource; input: string; /** 当前阶段可读写的条目列表 */ entries: KnowledgeEntry[]; /** 阶段间共享的元数据 */ metadata: Record; /** 事件总线引用 */ bus: EventBus; } /** 管线阶段执行结果 */ export interface StageResult { /** 处理后的条目列表(替换 context.entries) */ entries: KnowledgeEntry[]; /** 阶段产出的元数据(合并到 context.metadata) */ metadata?: Record; /** 是否中断管线(后续阶段不再执行) */ halt?: boolean; /** 中断原因 */ haltReason?: string; } /** 管线阶段接口 */ export interface PipelineStageHandler { /** 阶段名称 */ readonly name: PipelineStage; /** 执行阶段逻辑 */ execute(context: StageContext): Promise; } /** 管线配置 */ export interface PipelineOrchestratorOptions { /** 要跳过的阶段名称列表 */ skipStages?: PipelineStage[]; /** 置信度阈值,低于此值的条目标记为 pending */ confidenceThreshold?: number; } /** 管线任务状态 */ export interface OrchestratorTask { id: string; status: 'pending' | 'running' | 'completed' | 'failed' | 'halted'; input: string; source: KnowledgeSource; entries: KnowledgeEntry[]; metadata: Record; completedStages: PipelineStage[]; skippedStages: PipelineStage[]; failedStage?: PipelineStage; haltReason?: string; error?: string; createdAt: Date; completedAt?: Date; } export declare class PipelineOrchestrator { readonly bus: EventBus; private readonly stages; private readonly skipStages; private readonly tasks; constructor(options?: PipelineOrchestratorOptions); /** * 注册管线阶段(按注册顺序执行) * FR-K01 AC4:新增处理阶段只需注册到管线 */ registerStage(handler: PipelineStageHandler): void; /** * 在指定阶段之前插入新阶段 */ registerStageBefore(handler: PipelineStageHandler, beforeStage: PipelineStage): void; /** * 在指定阶段之后插入新阶段 */ registerStageAfter(handler: PipelineStageHandler, afterStage: PipelineStage): void; /** * 动态设置要跳过的阶段 */ setSkipStages(stages: PipelineStage[]): void; /** * 获取已注册的阶段列表(按执行顺序) */ getRegisteredStages(): PipelineStage[]; /** * 提交输入到管线,异步执行 * 返回任务 ID */ submit(input: string, source: KnowledgeSource): string; /** * 同步执行管线(等待完成) */ execute(input: string, source: KnowledgeSource): Promise; getTask(taskId: string): OrchestratorTask | undefined; private runPipeline; private emitEvent; destroy(): void; } //# sourceMappingURL=pipeline-orchestrator.d.ts.map