omp-worker-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +263 -0
- package/README.zh-CN.md +260 -0
- package/bin/omp-worker-mcp.mjs +34 -0
- package/dist/group-orchestrator.js +390 -0
- package/dist/group-orchestrator.js.map +1 -0
- package/dist/group-runner.js +13 -0
- package/dist/group-runner.js.map +1 -0
- package/dist/index.js +892 -0
- package/dist/index.js.map +1 -0
- package/dist/job-store.js +603 -0
- package/dist/job-store.js.map +1 -0
- package/dist/protocol.js +123 -0
- package/dist/protocol.js.map +1 -0
- package/dist/runner.js +230 -0
- package/dist/runner.js.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 omp-worker-mcp contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# omp-worker-mcp
|
|
4
|
+
|
|
5
|
+
**Durable Model Context Protocol (MCP) server for delegating asynchronous coding tasks and DAG workflows to local Oh My Pi (OMP) CLI sub-agents.**
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="README.md">English</a> •
|
|
9
|
+
<a href="README.zh-CN.md">简体中文</a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
[](LICENSE)
|
|
13
|
+
[](package.json)
|
|
14
|
+
[](https://github.com/divenire990/omp-worker-mcp/actions/workflows/ci.yml)
|
|
15
|
+
[](https://modelcontextprotocol.io/)
|
|
16
|
+
[](https://m8ven.ai/mcp/divenire990-omp-worker-mcp-4fc9xm)
|
|
17
|
+
|
|
18
|
+
<br />
|
|
19
|
+
|
|
20
|
+
<img src="assets/orchestration.gif" alt="Async DAG Orchestration Flow" width="800" />
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<em>Asynchronous task execution, DAG dependency resolution, path ownership isolation, and structured result verification.</em>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
[Quick Start](#installation-quick-start) • [Author Experience](#author-workflow-experience) • [MCP Configuration](#mcp-client-configuration) • [Configuration](#configuration-environment-variables) • [State Lifecycle](#state-lifecycle-retention-restart-recovery) • [Available Tools](#available-mcp-tools) • [Safety Contract](#task-safety-ownership-contract) • [Compatibility](#compatibility-changelog) • [Upstream Attribution](#upstream-attribution-support-boundaries)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Key Highlights
|
|
33
|
+
|
|
34
|
+
- ⚡ **Asynchronous Delegated Execution**: Offload heavy coding, refactoring, and exploration tasks to background OMP worker instances without blocking your main conversation session.
|
|
35
|
+
- 🔀 **Topological DAG Orchestration**: Execute interdependent batch tasks with automatic topological sorting, concurrency control, and dependency propagation.
|
|
36
|
+
- 🛡️ **Workspace Path Isolation**: Enforce explicit write-path boundaries and prevent overlapping file modifications between concurrent tasks.
|
|
37
|
+
- 🔍 **Supervised Resumption & Envelopes**: Inspect interim logs in real time, extract structured JSON outcome envelopes (`OMP_WORKER_RESULT`), and supply supervisory guidance to retry or adjust tasks.
|
|
38
|
+
- 💾 **Persistent State & Configurable Retention**: File-backed state persistence for job metadata and logs with configurable time-to-live (TTL) and disk capacity bounds.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Author Workflow Experience
|
|
43
|
+
|
|
44
|
+
In the author's daily local workflow, `omp-worker-mcp` is configured with **Gemini 3.7 Flash** as the underlying model for background OMP workers. Within the author's personal Antigravity account and quota environment, where model quotas are relatively generous, this setup has provided a very fast and dependable subjective experience across multi-step coding, research, and batch orchestration workflows.
|
|
45
|
+
|
|
46
|
+
> **Disclaimer & Boundary Notice**:
|
|
47
|
+
> This note reflects the author's personal setup and qualitative workflow experience only. It is **not** an independent benchmark, performance guarantee, or formal service commitment. Model availability, generation speed, quota allocations, and task execution quality vary significantly across different accounts, regions, model versions, task scopes, and local runtime environments. Neither Google Gemini nor Antigravity endorses or sponsors this project.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Upstream Attribution & Support Boundaries
|
|
52
|
+
|
|
53
|
+
- **External Upstream CLI**: This project interfaces with [Oh My Pi (OMP)](https://github.com/can1357/oh-my-pi), an open-source tool released under the [MIT License](https://github.com/can1357/oh-my-pi/blob/main/LICENSE).
|
|
54
|
+
- **Package Scope**: The upstream OMP CLI binary is **not bundled** in this package. Users must install and configure their own local instance of the OMP CLI.
|
|
55
|
+
- **Runtime Requirements**:
|
|
56
|
+
- Node.js **>= 22.0.0** (relies on native ECMAScript Modules and standard library capabilities).
|
|
57
|
+
- Users are responsible for complying with the OMP CLI license and terms applicable to their environment.
|
|
58
|
+
- **Platform Support**:
|
|
59
|
+
- **Windows** (win32) and **macOS** (Darwin / Apple Silicon, verified with real Node 22+ and OMP CLI E2E testing) are fully verified and supported.
|
|
60
|
+
- **Linux** (x86_64, aarch64) is an architectural design target and remains to be verified in production environments.
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Features
|
|
64
|
+
|
|
65
|
+
- **Asynchronous Task Delegation**: Launch background coding workers for long-running workflows while keeping the primary conversational agent responsive.
|
|
66
|
+
- **DAG & Batch Orchestration**: Run interdependent batch tasks with automatic dependency resolution, concurrency limiting, and failure containment.
|
|
67
|
+
- **Strict Task Safety & Ownership**: Built-in validation checks prevent parallel tasks from declaring overlapping write paths within the same workspace.
|
|
68
|
+
- **Continuous Supervision & Feedback**: Stream logs, inspect structured verification details, and inject guidance into failed or blocked jobs.
|
|
69
|
+
- **Conservative State Storage**: Safely persists job metadata, prompts, and output logs to disk with optional configurable cleanup policies.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Installation & Quick Start
|
|
74
|
+
|
|
75
|
+
### Current Installation: Building from Source
|
|
76
|
+
|
|
77
|
+
Before the package is published to the npm registry, building and running from source is the currently available path:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# 1. Clone the repository
|
|
81
|
+
git clone https://github.com/divenire990/omp-worker-mcp.git
|
|
82
|
+
cd omp-worker-mcp
|
|
83
|
+
|
|
84
|
+
# 2. Install dependencies
|
|
85
|
+
npm ci
|
|
86
|
+
|
|
87
|
+
# 3. Build TypeScript to dist/
|
|
88
|
+
npm run build
|
|
89
|
+
|
|
90
|
+
# 4. Run test suite
|
|
91
|
+
npm test
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Post-Publish Quick Start: Running via npx or global npm install
|
|
95
|
+
|
|
96
|
+
Once published to the npm registry, you can run `omp-worker-mcp` directly without cloning the repository:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Run directly via npx (post-publish)
|
|
100
|
+
npx omp-worker-mcp
|
|
101
|
+
|
|
102
|
+
# Or install globally (post-publish)
|
|
103
|
+
npm install -g omp-worker-mcp
|
|
104
|
+
omp-worker-mcp --help
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## MCP Client Configuration
|
|
108
|
+
|
|
109
|
+
`omp-worker-mcp` communicates over standard I/O (stdio). Below are configuration examples for various MCP clients.
|
|
110
|
+
|
|
111
|
+
### Codex Configuration (`config.toml`)
|
|
112
|
+
|
|
113
|
+
#### Using Local Source Build (Currently Available)
|
|
114
|
+
```toml
|
|
115
|
+
[mcp_servers.omp-worker]
|
|
116
|
+
command = "node"
|
|
117
|
+
args = ["/path/to/omp-worker-mcp/dist/index.js"]
|
|
118
|
+
|
|
119
|
+
[mcp_servers.omp-worker.env]
|
|
120
|
+
OMP_WORKER_OMP_COMMAND = "omp"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Using npx (Available Once Published to npm)
|
|
124
|
+
```toml
|
|
125
|
+
[mcp_servers.omp-worker]
|
|
126
|
+
command = "npx"
|
|
127
|
+
args = ["-y", "omp-worker-mcp"]
|
|
128
|
+
|
|
129
|
+
[mcp_servers.omp-worker.env]
|
|
130
|
+
OMP_WORKER_OMP_COMMAND = "omp"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Claude Desktop Configuration (`claude_desktop_config.json`)
|
|
134
|
+
|
|
135
|
+
#### Using Local Source Build (Currently Available)
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"mcpServers": {
|
|
139
|
+
"omp-worker": {
|
|
140
|
+
"command": "node",
|
|
141
|
+
"args": ["/path/to/omp-worker-mcp/dist/index.js"],
|
|
142
|
+
"env": {
|
|
143
|
+
"OMP_WORKER_OMP_COMMAND": "omp"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### Using npx (Available Once Published to npm)
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"mcpServers": {
|
|
154
|
+
"omp-worker": {
|
|
155
|
+
"command": "npx",
|
|
156
|
+
"args": ["-y", "omp-worker-mcp"],
|
|
157
|
+
"env": {
|
|
158
|
+
"OMP_WORKER_OMP_COMMAND": "omp"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Configuration & Environment Variables
|
|
168
|
+
|
|
169
|
+
All settings can be configured via environment variables in your system or within the MCP client configuration.
|
|
170
|
+
|
|
171
|
+
| Variable | Description | Default |
|
|
172
|
+
| :--- | :--- | :--- |
|
|
173
|
+
| `OMP_WORKER_OMP_COMMAND` | Path or executable name for the OMP CLI binary. | `omp` |
|
|
174
|
+
| `OMP_WORKER_OMP_PREFIX_ARGS` | JSON array string of arguments prepended to OMP CLI invocations (e.g. `["--profile", "default"]`). | `[]` |
|
|
175
|
+
| `OMP_WORKER_STATE_DIR` | Base directory for storing job states, prompt files, and execution logs. | `~/.codex/state/omp-worker` |
|
|
176
|
+
| `OMP_WORKER_BROWSER_RULES` | Optional custom browser automation instructions injected into worker prompts. | *(none)* |
|
|
177
|
+
| `OMP_WORKER_RETENTION_TTL_SECONDS` | Optional retention TTL in seconds for terminal job/group records. Unset disables TTL cleanup. | *(none)* |
|
|
178
|
+
| `OMP_WORKER_RETENTION_MAX_BYTES` | Optional maximum disk storage in bytes for terminal records. Unset disables size cleanup. | *(none)* |
|
|
179
|
+
| `OMP_WORKER_AUTO_CLEANUP_ON_START` | Optional boolean (`"true"` / `"1"`) to trigger a cleanup sweep once when MCP server starts. | `false` |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## State Lifecycle, Retention & Restart Recovery
|
|
184
|
+
|
|
185
|
+
### On-Disk Directory Layout
|
|
186
|
+
|
|
187
|
+
All state records are stored under `OMP_WORKER_STATE_DIR` (defaults to `~/.codex/state/omp-worker`):
|
|
188
|
+
```text
|
|
189
|
+
~/.codex/state/omp-worker/
|
|
190
|
+
├── jobs/
|
|
191
|
+
│ └── job-<timestamp>-<hash>/
|
|
192
|
+
│ ├── job.json # Job metadata, parameters, and status
|
|
193
|
+
│ ├── cancel.request.json # Cancellation signal (if requested)
|
|
194
|
+
│ ├── attempt-01.prompt.md # Generated prompt for attempt 1
|
|
195
|
+
│ ├── stdout.log # Execution standard output
|
|
196
|
+
│ └── stderr.log # Execution standard error
|
|
197
|
+
└── groups/
|
|
198
|
+
└── group-<timestamp>-<hash>/
|
|
199
|
+
├── group.json # Batch DAG metadata, tasks, and status
|
|
200
|
+
└── cancel.request.json # Group cancellation signal (if requested)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Retention and Cleanup Policies
|
|
204
|
+
|
|
205
|
+
- **Conservative by Default**: By default, `omp-worker-mcp` **never automatically deletes completed or historical records**, preventing unexpected data loss.
|
|
206
|
+
- **Explicit Cleanup Rules**: Users can opt in to automatic retention by setting `OMP_WORKER_RETENTION_TTL_SECONDS` (pruning terminal records older than N seconds) or `OMP_WORKER_RETENTION_MAX_BYTES` (pruning oldest terminal records when total disk usage exceeds threshold).
|
|
207
|
+
- **Protection for Active Jobs**: Non-terminal records (`dispatched`, `running`, `pending`, `validating`, `cancelling`) are **strictly protected and never pruned**.
|
|
208
|
+
- **Corrupted Record Protection**: Any record that cannot be verified as terminal is preserved to prevent accidental deletion. Symbolic links within state directories are rejected and never traversed.
|
|
209
|
+
- **Transparent Diagnostics**: Cleanup failures or permission issues are surfaced in structured error logs rather than silently ignored.
|
|
210
|
+
|
|
211
|
+
### Server Restart & Crash Recovery
|
|
212
|
+
|
|
213
|
+
- **Metadata Persistence**: Job and DAG group metadata are written atomically to disk. Dispatched and completed task records remain fully accessible across server restarts via `omp_result` and `omp_wait`.
|
|
214
|
+
- **Process Decoupling**: If the MCP server restarts while an external worker process is executing, the server does not attempt unmanaged re-attachment to orphaned processes; the persisted state and captured logs accurately reflect the recorded state.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Available MCP Tools
|
|
219
|
+
|
|
220
|
+
### Single Task Delegation Tools
|
|
221
|
+
|
|
222
|
+
| Tool | Purpose |
|
|
223
|
+
| :--- | :--- |
|
|
224
|
+
| `omp_run_compact` | **Recommended for single tasks**: Delegates a coding task and waits up to `wait_seconds` for completion in one turn, returning a compact summary. |
|
|
225
|
+
| `omp_delegate` | Low-level dispatch: Spawns an asynchronous background worker and immediately returns a `job_id`. |
|
|
226
|
+
| `omp_wait` | Waits for a running background job to finish or poll until a timeout is reached. |
|
|
227
|
+
| `omp_result` | Inspects full attempt history, execution logs, generated artifacts, and parsed structured outcome envelopes. |
|
|
228
|
+
| `omp_continue` | Injects supervisory guidance/correction into a failed or blocked task to trigger a new attempt within the same session. |
|
|
229
|
+
| `omp_cancel` | Gracefully terminates a running task and its spawned child process tree. |
|
|
230
|
+
|
|
231
|
+
### Batch & DAG Orchestration Tools
|
|
232
|
+
|
|
233
|
+
| Tool | Purpose |
|
|
234
|
+
| :--- | :--- |
|
|
235
|
+
| `omp_run_batch_compact` | **Recommended for multi-task workflows**: Spawns an interdependent batch task graph (DAG) with concurrency limits and waits for aggregated completion. |
|
|
236
|
+
| `omp_wait_group` | Waits for an asynchronous batch task group to make progress or complete. |
|
|
237
|
+
| `omp_cancel_group` | Cancels all active and queued tasks within a batch task group. |
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Task Safety & Ownership Contract
|
|
242
|
+
|
|
243
|
+
1. **Write vs. Read-Only Boundaries**:
|
|
244
|
+
- `write` tasks must explicitly declare the file paths they own via `ownership_paths`.
|
|
245
|
+
- `read_only` tasks are prohibited from performing workspace modifications.
|
|
246
|
+
2. **DAG Overlap Verification**:
|
|
247
|
+
- Parallel tasks within the same batch cannot declare overlapping write boundaries.
|
|
248
|
+
- Tasks operating on shared paths must declare explicit linear dependencies (`depends_on`).
|
|
249
|
+
3. **Structured Verification Contract**:
|
|
250
|
+
- Subagents deliver final results using the structured `OMP_WORKER_RESULT` format, returning status, summary, modified artifacts, verification checks, and remaining items.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Compatibility & Changelog
|
|
255
|
+
|
|
256
|
+
- **Upgrade & Versioning Policies**: Review [COMPATIBILITY.md](./COMPATIBILITY.md) for public contract definitions, deprecation policies, and upgrade guarantees.
|
|
257
|
+
- **Release History**: Review [CHANGELOG.md](./CHANGELOG.md) for notable changes across releases.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## License
|
|
262
|
+
|
|
263
|
+
This project is licensed under the [MIT License](LICENSE).
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# omp-worker-mcp
|
|
4
|
+
|
|
5
|
+
**用于将异步编码任务和 DAG 工作流委托给本地 Oh My Pi (OMP) CLI 子 Agent 执行的持久化模型上下文协议(MCP)服务器。**
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="README.md">English</a> •
|
|
9
|
+
<a href="README.zh-CN.md">简体中文</a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
[](LICENSE)
|
|
13
|
+
[](package.json)
|
|
14
|
+
[](https://github.com/divenire990/omp-worker-mcp/actions/workflows/ci.yml)
|
|
15
|
+
[](https://modelcontextprotocol.io/)
|
|
16
|
+
|
|
17
|
+
<br />
|
|
18
|
+
|
|
19
|
+
<img src="assets/orchestration.gif" alt="异步 DAG 编排流程" width="800" />
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<em>异步任务执行、DAG 依赖解析、路径所有权隔离与结构化结果校验。</em>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
[快速开始](#安装与快速开始) • [作者实测体验](#作者实测体验) • [MCP 客户端配置](#mcp-客户端配置) • [配置说明](#配置说明与环境变量) • [状态生命周期](#状态生命周期保留策略与重启恢复) • [可用工具](#可用-mcp-工具) • [安全与所有权约束](#任务安全与所有权约束) • [兼容性政策](#兼容性政策与变更记录) • [上游归属与支持边界](#上游归属与支持边界)
|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 核心亮点
|
|
32
|
+
|
|
33
|
+
- ⚡ **异步委托执行**:将繁重的编码、重构与调研任务下发给后台 OMP Worker 实例,主对话会话无需等待或被阻塞。
|
|
34
|
+
- 🔀 **拓扑 DAG 编排**:执行相互依赖的批量任务,支持自动拓扑排序、并发控制与依赖上下文传递。
|
|
35
|
+
- 🛡️ **工作区路径隔离**:强制执行严格的写路径边界约束,防止并发任务之间发生文件写入冲突。
|
|
36
|
+
- 🔍 **持续监督与结构化信封**:支持实时查看运行日志、提取结构化 JSON 结果信封(`OMP_WORKER_RESULT`),并向任务注入监督指导以进行重试或纠错。
|
|
37
|
+
- 💾 **持久化状态与可配置生命周期**:基于磁盘文件的任务元数据与日志持久化,支持可配置的保留时间(TTL)与磁盘容量上限。
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 作者实测体验
|
|
42
|
+
|
|
43
|
+
在作者个人的日常本地工作流中,`omp-worker-mcp` 配置了 **Gemini 3.7 Flash** 作为后台 OMP Worker 的底层运行模型。在作者个人的 Antigravity 账户与配额环境中(配额相对充裕),该配置在多步骤编码、技术调研以及批量任务编排等场景下,主观体验上响应迅速且执行稳定可靠。
|
|
44
|
+
|
|
45
|
+
> **免责声明与使用边界**:
|
|
46
|
+
> 本节仅代表作者个人的实际工作流配置与主观使用体验,**不构成**任何独立的性能基准测试、质量保证或服务承诺。模型的可用性、响应速度、可用配额以及实际任务生成效果会因账户类型、所在地区、模型版本迭代、任务规模及本地运行环境的不同而存在差异。本项目未获得 Google Gemini 或 Antigravity 的任何官方背书或赞助。
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 上游归属与支持边界
|
|
51
|
+
|
|
52
|
+
- **外部上游 CLI**:本项目调用 [Oh My Pi (OMP)](https://github.com/can1357/oh-my-pi),该上游开源工具基于 [MIT 许可证](https://github.com/can1357/oh-my-pi/blob/main/LICENSE) 发布。
|
|
53
|
+
- **分发边界**:上游 OMP CLI 二进制文件**不随本 npm 包打包分发**。用户需在本地自行安装并配置好 OMP CLI 运行环境。
|
|
54
|
+
- **运行环境要求**:
|
|
55
|
+
- Node.js **>= 22.0.0**(依赖原生 ECMAScript Modules 与标准库能力)。
|
|
56
|
+
- 用户有责任遵守适用于其自身环境的 OMP CLI 许可证及使用条款。
|
|
57
|
+
- **平台支持**:
|
|
58
|
+
- **Windows** (win32) 与 **macOS** (Darwin / Apple Silicon,经由真实 Node 22+ 与 OMP CLI E2E 完整验证) 均已验证支持。
|
|
59
|
+
- **Linux** (x86_64, aarch64) 目前为架构设计目标,待在生产环境中进一步验证。
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 功能特性
|
|
63
|
+
|
|
64
|
+
- **异步委托执行**:随时发起独立的后台子 Agent 编码任务,主会话保持流畅交互。
|
|
65
|
+
- **DAG 与批处理编排**:支持运行具有拓扑依赖关系的批量任务组,提供并发度限制、自动依赖传递与故障隔离。
|
|
66
|
+
- **严格的任务安全与所有权**:内置校验机制,防止多个并发任务在同一工作区写入重叠路径。
|
|
67
|
+
- **持续监督与反馈机制**:实时流式读取日志、解析结构化 JSON 结果信封,并在失败或阻塞时注入指导继续执行。
|
|
68
|
+
- **保守的状态持久化**:安全保存任务状态、提示词与日志,并支持可选的用户显式清理策略。
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 安装与快速开始
|
|
73
|
+
|
|
74
|
+
### 当前安装方式:源码编译与本地开发
|
|
75
|
+
|
|
76
|
+
在 npm 官方包正式发布上线之前,通过源码构建与运行是当前可用的使用路径:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# 1. 克隆代码仓库
|
|
80
|
+
git clone https://github.com/divenire990/omp-worker-mcp.git
|
|
81
|
+
cd omp-worker-mcp
|
|
82
|
+
|
|
83
|
+
# 2. 安装依赖
|
|
84
|
+
npm ci
|
|
85
|
+
|
|
86
|
+
# 3. 编译 TypeScript 到 dist/
|
|
87
|
+
npm run build
|
|
88
|
+
|
|
89
|
+
# 4. 运行测试套件
|
|
90
|
+
npm test
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 发布后快速启动:通过 npx 或全局 npm 安装运行
|
|
94
|
+
|
|
95
|
+
一旦包正式发布至 npm 注册表,您即可无需克隆仓库直接运行 `omp-worker-mcp`:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# 直接通过 npx 启动(发布后可用)
|
|
99
|
+
npx omp-worker-mcp
|
|
100
|
+
|
|
101
|
+
# 或全局安装后运行(发布后可用)
|
|
102
|
+
npm install -g omp-worker-mcp
|
|
103
|
+
omp-worker-mcp --help
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## MCP 客户端配置
|
|
107
|
+
|
|
108
|
+
`omp-worker-mcp` 通过标准输入输出(stdio)进行通信。以下是常用 MCP 客户端的配置示例。
|
|
109
|
+
|
|
110
|
+
### Codex 配置示例 (`config.toml`)
|
|
111
|
+
|
|
112
|
+
#### 使用本地源码构建运行(当前可用)
|
|
113
|
+
```toml
|
|
114
|
+
[mcp_servers.omp-worker]
|
|
115
|
+
command = "node"
|
|
116
|
+
args = ["/path/to/omp-worker-mcp/dist/index.js"]
|
|
117
|
+
|
|
118
|
+
[mcp_servers.omp-worker.env]
|
|
119
|
+
OMP_WORKER_OMP_COMMAND = "omp"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### 使用 npx 运行(待发布至 npm 后可用)
|
|
123
|
+
```toml
|
|
124
|
+
[mcp_servers.omp-worker]
|
|
125
|
+
command = "npx"
|
|
126
|
+
args = ["-y", "omp-worker-mcp"]
|
|
127
|
+
|
|
128
|
+
[mcp_servers.omp-worker.env]
|
|
129
|
+
OMP_WORKER_OMP_COMMAND = "omp"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Claude Desktop 配置示例 (`claude_desktop_config.json`)
|
|
133
|
+
|
|
134
|
+
#### 使用本地源码构建运行(当前可用)
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"omp-worker": {
|
|
139
|
+
"command": "node",
|
|
140
|
+
"args": ["/path/to/omp-worker-mcp/dist/index.js"],
|
|
141
|
+
"env": {
|
|
142
|
+
"OMP_WORKER_OMP_COMMAND": "omp"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### 使用 npx 运行(待发布至 npm 后可用)
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"mcpServers": {
|
|
153
|
+
"omp-worker": {
|
|
154
|
+
"command": "npx",
|
|
155
|
+
"args": ["-y", "omp-worker-mcp"],
|
|
156
|
+
"env": {
|
|
157
|
+
"OMP_WORKER_OMP_COMMAND": "omp"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## 配置说明与环境变量
|
|
165
|
+
|
|
166
|
+
支持通过环境变量(或在 MCP 客户端配置中)进行灵活配置。
|
|
167
|
+
|
|
168
|
+
| 环境变量 | 说明 | 默认值 |
|
|
169
|
+
| :--- | :--- | :--- |
|
|
170
|
+
| `OMP_WORKER_OMP_COMMAND` | OMP CLI 二进制文件的路径或可执行文件名。 | `omp` |
|
|
171
|
+
| `OMP_WORKER_OMP_PREFIX_ARGS` | 每次调用 OMP CLI 时前置添加的参数(JSON 数组字符串,例如 `["--profile", "default"]`)。 | `[]` |
|
|
172
|
+
| `OMP_WORKER_STATE_DIR` | 用于保存任务状态、尝试记录、日志与产物的根目录路径。 | `~/.codex/state/omp-worker` |
|
|
173
|
+
| `OMP_WORKER_BROWSER_RULES` | 可选:注入到任务提示词中的自定义浏览器自动化指令。 | *(无)* |
|
|
174
|
+
| `OMP_WORKER_RETENTION_TTL_SECONDS` | 可选:终态任务/任务组的保留时间(秒)。未设置时不基于时间自动清理。 | *(无)* |
|
|
175
|
+
| `OMP_WORKER_RETENTION_MAX_BYTES` | 可选:状态目录允许占用的最大磁盘字节数。未设置时不基于容量上限自动清理。 | *(无)* |
|
|
176
|
+
| `OMP_WORKER_AUTO_CLEANUP_ON_START` | 可选:布尔值(`"true"` 或 `"1"`),在 MCP 服务器启动时自动执行一次清理。 | `false` |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 状态生命周期、保留策略与重启恢复
|
|
181
|
+
|
|
182
|
+
### 磁盘目录结构
|
|
183
|
+
|
|
184
|
+
所有状态记录均存储在 `OMP_WORKER_STATE_DIR` 目录下(默认为 `~/.codex/state/omp-worker`):
|
|
185
|
+
```text
|
|
186
|
+
~/.codex/state/omp-worker/
|
|
187
|
+
├── jobs/
|
|
188
|
+
│ └── job-<时间戳>-<哈希>/
|
|
189
|
+
│ ├── job.json # 任务元数据、参数与当前状态
|
|
190
|
+
│ ├── cancel.request.json # 取消信号文件(若已发起取消)
|
|
191
|
+
│ ├── attempt-01.prompt.md # 第 1 次尝试生成的提示词
|
|
192
|
+
│ ├── stdout.log # 任务执行标准输出
|
|
193
|
+
│ └── stderr.log # 任务执行标准错误
|
|
194
|
+
└── groups/
|
|
195
|
+
└── group-<时间戳>-<哈希>/
|
|
196
|
+
├── group.json # 批量 DAG 任务组元数据、任务列表与状态
|
|
197
|
+
└── cancel.request.json # 任务组取消信号文件(若已发起取消)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 保留与清理策略
|
|
201
|
+
|
|
202
|
+
- **默认保守保留**:默认情况下,`omp-worker-mcp` **绝不自动删除任何已完成或历史记录**,防止用户数据或日志意外丢失。
|
|
203
|
+
- **显式清理规则**:用户可通过配置 `OMP_WORKER_RETENTION_TTL_SECONDS`(清理超过指定秒数的终态记录)或 `OMP_WORKER_RETENTION_MAX_BYTES`(按时间由旧到新清理终态记录直至满足字节上限)启用自动清理。
|
|
204
|
+
- **运行中任务保护**:处于非终态(`dispatched`、`running`、`pending`、`validating`、`cancelling` 等)的任务与任务组**受到严格保护,绝不被清理**。
|
|
205
|
+
- **损坏记录安全保护**:无法确认其是否为终态的损坏文件不会被误删;状态目录中的符号链接将被拒绝且不会被递归跟随。
|
|
206
|
+
- **透明的故障可见性**:清理过程中的权限异常或读写错误会完整记录在错误输出中,不会被静默吞掉。
|
|
207
|
+
|
|
208
|
+
### 服务器重启与恢复机制
|
|
209
|
+
|
|
210
|
+
- **元数据持久化**:任务与批处理组的元数据均原子写入磁盘。在 MCP 服务器重启后,所有已分发与已完成的任务依然可以通过 `omp_result` 与 `omp_wait` 完整读取。
|
|
211
|
+
- **进程解耦**:若 MCP 服务器在外部任务运行期间意外退出,服务器不会在重启后对失控的孤儿进程进行静默接管,持久化的元数据与日志将忠实反映记录的状态。
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 可用 MCP 工具
|
|
216
|
+
|
|
217
|
+
### 单任务委托工具
|
|
218
|
+
|
|
219
|
+
| 工具名称 | 用途 |
|
|
220
|
+
| :--- | :--- |
|
|
221
|
+
| `omp_run_compact` | **单任务推荐**:便捷工具,委托单个任务并在单轮对话中等待最多 `wait_seconds` 秒以获取压缩结果。 |
|
|
222
|
+
| `omp_delegate` | 基础委托:异步创建后台 Worker 执行编码任务,并立即返回 `job_id`。 |
|
|
223
|
+
| `omp_wait` | 等待正在运行的后台任务执行完成,或轮询直至超时。 |
|
|
224
|
+
| `omp_result` | 获取任务的完整尝试历史、执行日志、产物输出及解析后的结构化结果信封。 |
|
|
225
|
+
| `omp_continue` | 向失败或阻塞的任务注入监督指导,在同一会话中发起新的执行尝试。 |
|
|
226
|
+
| `omp_cancel` | 优雅终止正在运行的任务及其子进程树。 |
|
|
227
|
+
|
|
228
|
+
### 批量任务与 DAG 编排工具
|
|
229
|
+
|
|
230
|
+
| 工具名称 | 用途 |
|
|
231
|
+
| :--- | :--- |
|
|
232
|
+
| `omp_run_batch_compact` | **多任务推荐**:创建具有依赖关系图(DAG)的并行/串行批量任务组,控制并发度并等待全部完成返回汇总结果。 |
|
|
233
|
+
| `omp_wait_group` | 等待异步批量任务组的执行推进或全部完成。 |
|
|
234
|
+
| `omp_cancel_group` | 取消批量任务组中所有正在运行及处于等待队列中的任务。 |
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 任务安全与所有权约束
|
|
239
|
+
|
|
240
|
+
1. **写入与只读隔离**:
|
|
241
|
+
- `write` 任务必须通过 `ownership_paths` 明确声明其拥有所有权的文件写入路径。
|
|
242
|
+
- `read_only` 任务被严格限制,禁止对工作区进行任何文件修改。
|
|
243
|
+
2. **DAG 冲突与重叠校验**:
|
|
244
|
+
- 同一组内并行运行的任务之间不得声明相互重叠的写入路径边界。
|
|
245
|
+
- 需要修改相同路径的任务必须显式声明线性的 DAG 依赖关系(`depends_on`)。
|
|
246
|
+
3. **结构化校验信封约定**:
|
|
247
|
+
- 每个执行完成的子任务均需遵循 `OMP_WORKER_RESULT` 格式返回结构化结果(包含 `status`, `summary`, `artifacts`, `verification`, `remaining`)。
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## 兼容性政策与变更记录
|
|
252
|
+
|
|
253
|
+
- **升级与版本政策**:请参阅 [COMPATIBILITY.md](./COMPATIBILITY.md) 了解公共契约定义、废弃过渡流程与版本兼容性保证。
|
|
254
|
+
- **变更日志**:请参阅 [CHANGELOG.md](./CHANGELOG.md) 了解各版本的详细更新与修复记录。
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 许可证
|
|
259
|
+
|
|
260
|
+
本项目基于 [MIT 许可证](LICENSE) 开源。
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
|
|
8
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
9
|
+
console.log(`omp-worker-mcp - Model Context Protocol (MCP) server for delegating coding tasks to OMP
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
omp-worker-mcp [options]
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
-h, --help Show this help message
|
|
16
|
+
-v, --version Show version number
|
|
17
|
+
|
|
18
|
+
By default, runs the MCP server over stdio for integration with MCP clients.`);
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
23
|
+
try {
|
|
24
|
+
const packageJsonPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
25
|
+
const pkg = JSON.parse(await readFile(packageJsonPath, "utf8"));
|
|
26
|
+
console.log(pkg.version || "1.0.0");
|
|
27
|
+
} catch {
|
|
28
|
+
console.log("1.0.0");
|
|
29
|
+
}
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Launch the MCP server
|
|
34
|
+
await import("../dist/index.js");
|