@ harness- engineering/ orchestrator (英语)
Orchestrator 守护进程用于向问题发送编码代理. 投出一个用于候选任务的发行跟踪器,管理平面工作空间,运行代理以解决问题,并更新跟踪器的进度.
建筑
┌──────────────────────────────────────────────────┐
│ Issue Tracker │
│ RoadmapTrackerAdapter · Linear Extension │
└──────────────────┬───────────────────────────────┘
▼
┌──────────────────────────────────────────────────┐
│ Intelligence Pipeline (optional) │
│ SEL (spec enrichment) → CML (complexity) → │
│ ConcernSignals → PESL (simulation + abort) │
│ (@harness-engineering/intelligence) │
└──────────────────┬───────────────────────────────┘
▼
┌──────────────────────────────────────────────────┐
│ Core State Machine │
│ Candidate Selection · Concurrency Control │
│ Model Routing (routeIssue + concern signals) │
│ Reconciliation · Retry Logic │
│ Event Sourcing (applyEvent → side effects) │
└──────────────────┬───────────────────────────────┘
▼
┌────────────────┐ ┌─────────────────┐
│ Agent Runner │ │ Workspaces │
│ Claude Backend│ │ WorkspaceManager│
│ Mock Backend │ │ WorkspaceHooks │
└───────┬────────┘ └────────┬────────┘
└────────┬───────────┘
▼
┌──────────────────────────────────────────────────┐
│ Prompt Rendering (LiquidJS) │
└──────────────────────────────────────────────────┘
快速启动
import { Orchestrator, WorkflowLoader } from '@harness-engineering/orchestrator';
// Load workflow definition (config + prompt template) from a harness.orchestrator.md file
const loader = new WorkflowLoader();
const result = await loader.loadWorkflow('./harness.orchestrator.md');
if (!result.ok) throw result.error;
const { config, promptTemplate } = result.value;
// Create and start the orchestrator
const orchestrator = new Orchestrator(config, promptTemplate);
await orchestrator.start();
核心概念
事件来源国家机器
管弦乐团采用事件源架构. 所有州的过渡都以事件为模式(OrchestratorEvent产生副作用(SideEffect:
import { applyEvent, createEmptyState } from '@harness-engineering/orchestrator';
import type { WorkflowConfig } from '@harness-engineering/types';
const state = createEmptyState(config); // config: WorkflowConfig
const { state: next, effects } = applyEvent(state, event);
// effects: DispatchEffect, StopEffect, ScheduleRetryEffect, etc.
候选人的甄选
问题在发送前进行排序和过滤:
import { sortCandidates, selectCandidates, isEligible } from '@harness-engineering/orchestrator';
const ranked = sortCandidates(issues);
const selected = selectCandidates(ranked, availableSlots);
情报管道整合
何时 config.intelligence.enabled 实值 true指挥员在每一滴滴中 都运行情报管道:
- 预线 对于每个候选问题,
preprocessIssue()运行SEL(光谱浓缩)和CML(复杂分),生产ConcernSignal[]输入到routeIssue()用于alwaysHuman分级,丰富谱被附在人类环境的升级上. - 后路线 ——针对本地流出的问题,PESL模拟运行. 若为
abort: true(信心 < 0.3), 调度会升级. - 执行后 - 打开
worker_exit,将执行结果记录在图表中,用于未来的CML历史评分.
被禁用( 默认) 时, 管道被全部跳过, 路由会使用空关切信号 .
见 @harness-engineering/intelligence 读取 用于整个管道文件.
代理后端
有两个后端:
ClaudeBackend使用 Claude API 生产后端MockBackend测试测试中确定性行为的后端
工作空间管理
每一次特工运行都会得到一个带有生命周期钩子的电平工作空间:
import { WorkspaceManager, WorkspaceHooks } from '@harness-engineering/orchestrator';
const manager = new WorkspaceManager(config);
const hooks = new WorkspaceHooks(config);
API 密码
整形仪
连接一切的主课:
start()- 开始投票和调度stop()- 顺利地关闭- 活动 :
state_change, (中文(简体) ),agent_event
核心职能
| 导出 | 说明 |
|---|---|
applyEvent | 将事件应用到状态, 返回新状态 + 副作用 |
createEmptyState | 创建初始空管弦乐状态 |
sortCandidates | 按优先权和资格划分的排名问题 |
selectCandidates | 在货币限额内选择顶级候选人 |
isEligible | 检查一个问题是否符合发送条件 |
getAvailableSlots | 获取可用的代理位数 |
canDispatch | 检查在当前状态下是否可能发送 |
reconcileRunningIssues | 校正当前追踪器状态的运行问题 |
calculateRetryDelayMs | 计算指数后退延迟, 以毫秒计 |
跟踪器适配器
| 导出 | 说明 |
|---|---|
RoadmapTrackerAdapter | 阅读问题 docs/roadmap.md |
LinearTrackerExtension | 以线性集成扩展跟踪 (计划) |
快速渲染
| 导出 | 说明 |
|---|---|
PromptRenderer | 代理提示的 Renders LiquidJS 模板 |
许可证
麻省理工学院