@donmai/core

中文文档
0.10.0发布于 2026/10/28MITTypeScriptES Module构建来源已验证近 30 天下载 1.9万

Multi-agent fleet management for coding agents — orchestrator, providers, crash recovery

原始使用文档
文档目录8 节
  1. Installation
  2. Quick Start
  3. What It Does
  4. Provider Abstraction
  5. Configuration
  6. Workflow Governor
  7. Related Packages
  8. License

@donmai/core

Core orchestrator for multi-agent fleet management. Turns your issue backlog into shipped code by coordinating coding agents (Claude, Codex, Amp) through an automated pipeline.

Part of the Donmai monorepo.

Installation

npm install @donmai/core @donmai/plugin-linear

Quick Start

import { createOrchestrator } from '@donmai/core'

const orchestrator = createOrchestrator({
  maxConcurrent: 3,
  // Default: '../{repoName}.wt/' (sibling directory)
})

// Process a single issue
await orchestrator.spawnAgentForIssue('PROJ-123')
await orchestrator.waitForAll()

// Check results
for (const agent of orchestrator.getAgents()) {
  console.log(`${agent.identifier}: ${agent.status}`)
  if (agent.pullRequestUrl) console.log(`  PR: ${agent.pullRequestUrl}`)
  if (agent.totalCostUsd) console.log(`  Cost: $${agent.totalCostUsd.toFixed(4)}`)
}

What It Does

  1. Issue selection — queries Linear for backlog issues, filters by project, selects by priority
  2. Worktree creation — creates isolated git worktrees per agent
  3. Agent spawning — delegates to providers (Claude, Codex, Amp)
  4. Stream processing — iterates AgentEvent from providers, emits activities to Linear
  5. Crash recovery — persists state to .agent/ directory, resumes on restart
  6. Inactivity timeout — monitors idle agents and stops them

Provider Abstraction

interface AgentProvider {
  readonly name: 'claude' | 'codex' | 'amp'
  spawn(config: AgentSpawnConfig): AgentHandle
  resume(sessionId: string, config: AgentSpawnConfig): AgentHandle
}

interface AgentHandle {
  sessionId: string | null
  stream: AsyncIterable<AgentEvent>
  injectMessage(text: string): Promise<void>
  stop(): Promise<void>
}

Provider resolution: AGENT_PROVIDER_{WORKTYPE} > AGENT_PROVIDER_{PROJECT} > AGENT_PROVIDER > 'claude'

Configuration

const orchestrator = createOrchestrator({
  provider: myProvider,            // Agent provider instance
  maxConcurrent: 3,                // Max concurrent agents
  project: 'MyProject',           // Filter by project
  // worktreePath defaults to '../{repoName}.wt/' (sibling directory)
  inactivityTimeoutMs: 300_000,   // 5 min idle timeout
  maxSessionTimeoutMs: 7_200_000, // 2 hour hard cap
  workTypeTimeouts: {
    qa: { inactivityTimeoutMs: 600_000 },
  },
})

Workflow Governor

The core package includes the Workflow Governor — a central lifecycle manager that observes all issues and decides what work to dispatch.

import {
  WorkflowGovernor,
  EventDrivenGovernor,
  InMemoryEventBus,
  InMemoryEventDeduplicator,
  type GovernorDependencies,
} from '@donmai/core'

// Poll-only mode (simple)
const governor = new WorkflowGovernor(
  { projects: ['MyProject'], scanIntervalMs: 60_000 },
  myDependencies,
)
governor.start()

// Event-driven mode (production)
const eventGovernor = new EventDrivenGovernor(
  {
    projects: ['MyProject'],
    eventBus: new InMemoryEventBus(),        // or RedisEventBus
    deduplicator: new InMemoryEventDeduplicator(), // or RedisEventDeduplicator
    pollIntervalMs: 300_000,                 // 5 min safety net
  },
  myDependencies,
)
await eventGovernor.start()

The governor evaluates each issue against status, active sessions, cooldowns, human overrides (HOLD/RESUME/PRIORITY), and workflow strategy to decide what action to take. See Architecture docs for details.

PackageDescription
@donmai/plugin-linearLinear issue tracker integration
@donmai/serverRedis work queue, distributed workers
@donmai/cliCLI tools
@donmai/nextjsNext.js webhook server

License

MIT

版本与发布记录

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

版本发布日期距今
0.10.0latest2026/10/2816 天前
0.9.152026/09/122 个月前
0.9.142026/08/252 个月前
0.9.132026/08/232 个月前
0.9.122026/08/232 个月前
0.9.112026/08/142 个月前

关于 @donmai/core 的常见问题

@donmai/core 是什么?

Multi-agent fleet management for coding agents — orchestrator, providers, crash recovery

如何安装 @donmai/core?

在项目目录运行 npm install @donmai/core,或使用 pnpm add / yarn add / bun add。

@donmai/core 支持 TypeScript 吗?

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

@donmai/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@donmai/core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.23.4。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@donmai/core 可以商用吗?

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

@donmai/core 的下载量有多少?

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

@donmai/core 还在维护吗?

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