@harness-engineering/orchestrator

中文文档
0.30.0发布于 2026/11/17MITTypeScriptESM + CJS构建来源已验证近 30 天下载 9477

Orchestrator daemon for dispatching coding agents to issues

原始使用文档
文档目录14 节
  1. Architecture
  2. Quick Start
  3. Core Concepts
  4. Event-Sourced State Machine
  5. Candidate Selection
  6. Intelligence Pipeline Integration
  7. Agent Backends
  8. Workspace Management
  9. API
  10. Orchestrator
  11. Core Functions
  12. Tracker Adapters
  13. Prompt Rendering
  14. License

@harness-engineering/orchestrator

Orchestrator daemon for dispatching coding agents to issues. Polls an issue tracker for candidate tasks, manages ephemeral workspaces, runs agents to resolve issues, and updates the tracker with progress.

Architecture

┌──────────────────────────────────────────────────┐
│                 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)           │
└──────────────────────────────────────────────────┘

Quick Start

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();

Core Concepts

Event-Sourced State Machine

The orchestrator uses an event-sourced architecture. All state transitions are modeled as events (OrchestratorEvent) that produce side effects (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.

Candidate Selection

Issues are ranked and filtered before dispatch:

import { sortCandidates, selectCandidates, isEligible } from '@harness-engineering/orchestrator';

const ranked = sortCandidates(issues);
const selected = selectCandidates(ranked, availableSlots);

Intelligence Pipeline Integration

When config.intelligence.enabled is true, the orchestrator runs the intelligence pipeline during each tick:

  1. Pre-routing — For each candidate issue, preprocessIssue() runs SEL (spec enrichment) and CML (complexity scoring), producing ConcernSignal[] that feed into routeIssue(). For alwaysHuman tiers, the enriched spec is attached to the escalation for human context.
  2. Post-routing — For locally-routed issues, PESL simulation runs. If abort: true (confidence < 0.3), the dispatch converts to an escalation.
  3. Post-execution — On worker_exit, execution outcomes are recorded into the graph for future CML historical scoring.

When disabled (default), the pipeline is skipped entirely and routing uses empty concern signals.

See @harness-engineering/intelligence README for full pipeline documentation.

Agent Backends

Two backends are available:

  • ClaudeBackend — Production backend using the Claude API
  • MockBackend — Test backend for deterministic behavior in tests

Workspace Management

Each agent run gets an ephemeral workspace with lifecycle hooks:

import { WorkspaceManager, WorkspaceHooks } from '@harness-engineering/orchestrator';

const manager = new WorkspaceManager(config);
const hooks = new WorkspaceHooks(config);

API

Orchestrator

The main class that ties everything together:

  • start() — Begin polling and dispatching
  • stop() — Gracefully shut down
  • Events: state_change, agent_event

Core Functions

ExportDescription
applyEventApply an event to state, returning new state + side effects
createEmptyStateCreate an initial empty orchestrator state
sortCandidatesRank issues by priority and eligibility
selectCandidatesSelect top candidates within concurrency limits
isEligibleCheck if an issue is eligible for dispatch
getAvailableSlotsGet number of available agent slots
canDispatchCheck if dispatch is possible given current state
reconcileRunningIssuesReconcile running issues against their current tracker states
calculateRetryDelayMsCompute exponential backoff delay, in milliseconds

Tracker Adapters

ExportDescription
RoadmapTrackerAdapterReads issues from docs/roadmap.md
LinearTrackerExtensionExtends tracking with Linear integration (planned)

Prompt Rendering

ExportDescription
PromptRendererRenders LiquidJS templates for agent prompts

License

MIT

版本与发布记录

@harness-engineering/orchestrator 共发布 70 个版本,首次发布于 2026/03/25;过去 12 个月发布了 70 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.30.0latest2026/11/17今天
0.29.02026/11/125 天前
0.28.02026/10/2027 天前
0.27.22026/09/241 个月前
0.27.12026/09/181 个月前
0.27.02026/09/172 个月前

关于 @harness-engineering/orchestrator 的常见问题

@harness-engineering/orchestrator 是什么?

Orchestrator daemon for dispatching coding agents to issues

如何安装 @harness-engineering/orchestrator?

在项目目录运行 npm install @harness-engineering/orchestrator,或使用 pnpm add / yarn add / bun add。

@harness-engineering/orchestrator 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@harness-engineering/orchestrator 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@harness-engineering/orchestrator 可以商用吗?

@harness-engineering/orchestrator 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@harness-engineering/orchestrator 的下载量有多少?

根据 npm 官方下载统计,@harness-engineering/orchestrator 在 2026/10/17 – 2026/11/15 这 30 天内被下载 9,477 次,日均约 316 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@harness-engineering/orchestrator 还在维护吗?

最新版本 0.30.0 发布于 2026/11/17(今天);至今共发布 70 个版本,其中过去 12 个月发布了 70 个;首次发布于 2026/03/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。