@openhorizon/workflows 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -0
  3. package/dist/cli.js +2162 -0
  4. package/package.json +52 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OpenHorizon
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,72 @@
1
+ # @openhorizon/workflows
2
+
3
+ Deterministic multi-agent workflow orchestration as an MCP server. Workflow
4
+ scripts (`agent()` / `parallel()` / `pipeline()` / `phase()` / `log()` /
5
+ `budget`) run in a hardened Node `vm` sandbox; each `agent()` call executes as
6
+ a fresh [Cursor SDK](https://cursor.com/docs/sdk/typescript) agent.
7
+
8
+ A faithful port of Claude Code's "dynamic workflows" (`Workflow` tool,
9
+ v2.1.170) to the launch-and-poll MCP shape: the same script contract, VM
10
+ membrane, determinism rules, concurrency caps, journal-based resume, and
11
+ pipeline-over-barrier orchestration semantics — usable from any MCP client
12
+ (Cursor, Claude Code, Codex, ...).
13
+
14
+ ## Setup
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "workflows": {
20
+ "command": "npx",
21
+ "args": ["-y", "@openhorizon/workflows"],
22
+ "env": { "CURSOR_API_KEY": "cursor_..." }
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ ## Tools
29
+
30
+ - `workflow` — launch (or resume) a run; returns immediately with a run ID.
31
+ - `workflow_status` — progress snapshot (phases, agents, logs, failures,
32
+ result); lists all runs without `runId`.
33
+ - `workflow_wait` — long-poll until terminal, capped at 55s per call.
34
+ - `workflow_stop` — abort a running workflow (resumable afterwards).
35
+
36
+ ## Configuration (env)
37
+
38
+ | Variable | Default | Meaning |
39
+ | --------------------------- | -------------------------- | --------------------------------------------------------- |
40
+ | `CURSOR_API_KEY` | — | Cursor API key the subagents bill to (required). |
41
+ | `WORKFLOWS_MODEL` | `auto` | Default model for subagents (`agent({model})` overrides). |
42
+ | `WORKFLOWS_MAX_CONCURRENCY` | `min(16, cores-2)` | Concurrent subagent cap per run. |
43
+ | `OPENHORIZON_WORKFLOWS_DIR` | `~/.openhorizon/workflows` | State home (runs, journals, results). |
44
+
45
+ ## Run state
46
+
47
+ One directory per run under the state home: `script.js` (the iterate/resume
48
+ handle), `journal.jsonl` (chained-hash agent cache backing
49
+ `resumeFromRunId`), `state.json` (status snapshot), `progress.jsonl` (event
50
+ log), `result.json` (the script's return value).
51
+
52
+ ## Divergences from the Claude Code original
53
+
54
+ - Completion is poll-based (`workflow_status` / `workflow_wait`) — MCP servers
55
+ cannot push a task notification into the host conversation.
56
+ - `budget` is a per-run output-token pool (set via the `tokenBudget` input),
57
+ not the host session's shared turn budget.
58
+ - Subagents use the server's configured model (`WORKFLOWS_MODEL`) rather than
59
+ inheriting the host's model.
60
+ - `agent({agentType})` and the `workflow()` nesting hook are not available in
61
+ this build; `agent({isolation:'remote'})` is unavailable exactly like gold.
62
+
63
+ ## Development
64
+
65
+ ```bash
66
+ pnpm install
67
+ pnpm --filter @openhorizon/workflows typecheck
68
+ pnpm --filter @openhorizon/workflows test
69
+ # Build + run (the server must run under Node, not Bun — the Cursor SDK's
70
+ # HTTP/2 stack crashes under Bun; bun is used for bundling only):
71
+ bun run build && node dist/cli.js
72
+ ```