@wundam/orchex 1.0.0-rc.1

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 (104) hide show
  1. package/LICENSE +65 -0
  2. package/README.md +332 -0
  3. package/bin/orchex.js +2 -0
  4. package/dist/artifacts.d.ts +132 -0
  5. package/dist/artifacts.js +832 -0
  6. package/dist/claude-executor.d.ts +31 -0
  7. package/dist/claude-executor.js +200 -0
  8. package/dist/commands.d.ts +36 -0
  9. package/dist/commands.js +264 -0
  10. package/dist/config.d.ts +100 -0
  11. package/dist/config.js +172 -0
  12. package/dist/context-builder.d.ts +46 -0
  13. package/dist/context-builder.js +506 -0
  14. package/dist/cost.d.ts +29 -0
  15. package/dist/cost.js +60 -0
  16. package/dist/execution-broadcaster.d.ts +18 -0
  17. package/dist/execution-broadcaster.js +17 -0
  18. package/dist/executors/base.d.ts +99 -0
  19. package/dist/executors/base.js +206 -0
  20. package/dist/executors/circuit-breaker.d.ts +36 -0
  21. package/dist/executors/circuit-breaker.js +109 -0
  22. package/dist/executors/deepseek-executor.d.ts +22 -0
  23. package/dist/executors/deepseek-executor.js +145 -0
  24. package/dist/executors/gemini-executor.d.ts +20 -0
  25. package/dist/executors/gemini-executor.js +176 -0
  26. package/dist/executors/index.d.ts +81 -0
  27. package/dist/executors/index.js +193 -0
  28. package/dist/executors/ollama-executor.d.ts +25 -0
  29. package/dist/executors/ollama-executor.js +184 -0
  30. package/dist/executors/openai-executor.d.ts +22 -0
  31. package/dist/executors/openai-executor.js +142 -0
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.js +115 -0
  34. package/dist/intelligence/anti-pattern-detector.d.ts +117 -0
  35. package/dist/intelligence/anti-pattern-detector.js +327 -0
  36. package/dist/intelligence/budget-enforcer.d.ts +119 -0
  37. package/dist/intelligence/budget-enforcer.js +226 -0
  38. package/dist/intelligence/context-optimizer.d.ts +111 -0
  39. package/dist/intelligence/context-optimizer.js +282 -0
  40. package/dist/intelligence/cost-tracker.d.ts +114 -0
  41. package/dist/intelligence/cost-tracker.js +183 -0
  42. package/dist/intelligence/deliverable-extractor.d.ts +134 -0
  43. package/dist/intelligence/deliverable-extractor.js +909 -0
  44. package/dist/intelligence/dependency-inferrer.d.ts +87 -0
  45. package/dist/intelligence/dependency-inferrer.js +403 -0
  46. package/dist/intelligence/diagnostics.d.ts +25 -0
  47. package/dist/intelligence/diagnostics.js +36 -0
  48. package/dist/intelligence/error-analyzer.d.ts +7 -0
  49. package/dist/intelligence/error-analyzer.js +76 -0
  50. package/dist/intelligence/file-chunker.d.ts +15 -0
  51. package/dist/intelligence/file-chunker.js +64 -0
  52. package/dist/intelligence/fix-stream-manager.d.ts +59 -0
  53. package/dist/intelligence/fix-stream-manager.js +212 -0
  54. package/dist/intelligence/heuristics.d.ts +23 -0
  55. package/dist/intelligence/heuristics.js +124 -0
  56. package/dist/intelligence/learning-engine.d.ts +157 -0
  57. package/dist/intelligence/learning-engine.js +433 -0
  58. package/dist/intelligence/learning-feedback.d.ts +96 -0
  59. package/dist/intelligence/learning-feedback.js +202 -0
  60. package/dist/intelligence/pattern-analyzer.d.ts +35 -0
  61. package/dist/intelligence/pattern-analyzer.js +189 -0
  62. package/dist/intelligence/plan-parser.d.ts +124 -0
  63. package/dist/intelligence/plan-parser.js +498 -0
  64. package/dist/intelligence/planner.d.ts +29 -0
  65. package/dist/intelligence/planner.js +86 -0
  66. package/dist/intelligence/self-healer.d.ts +16 -0
  67. package/dist/intelligence/self-healer.js +84 -0
  68. package/dist/intelligence/slicing-metrics.d.ts +62 -0
  69. package/dist/intelligence/slicing-metrics.js +202 -0
  70. package/dist/intelligence/slicing-templates.d.ts +81 -0
  71. package/dist/intelligence/slicing-templates.js +420 -0
  72. package/dist/intelligence/split-suggester.d.ts +69 -0
  73. package/dist/intelligence/split-suggester.js +176 -0
  74. package/dist/intelligence/stream-generator.d.ts +90 -0
  75. package/dist/intelligence/stream-generator.js +452 -0
  76. package/dist/logger.d.ts +34 -0
  77. package/dist/logger.js +83 -0
  78. package/dist/logging.d.ts +5 -0
  79. package/dist/logging.js +38 -0
  80. package/dist/manifest.d.ts +56 -0
  81. package/dist/manifest.js +254 -0
  82. package/dist/metrics.d.ts +35 -0
  83. package/dist/metrics.js +75 -0
  84. package/dist/orchestrator.d.ts +35 -0
  85. package/dist/orchestrator.js +723 -0
  86. package/dist/ownership.d.ts +44 -0
  87. package/dist/ownership.js +250 -0
  88. package/dist/semaphore.d.ts +12 -0
  89. package/dist/semaphore.js +34 -0
  90. package/dist/telemetry/telemetry-types.d.ts +85 -0
  91. package/dist/telemetry/telemetry-types.js +1 -0
  92. package/dist/tier-gating.d.ts +24 -0
  93. package/dist/tier-gating.js +88 -0
  94. package/dist/tiers.d.ts +92 -0
  95. package/dist/tiers.js +108 -0
  96. package/dist/tools.d.ts +18 -0
  97. package/dist/tools.js +1363 -0
  98. package/dist/types.d.ts +740 -0
  99. package/dist/types.js +160 -0
  100. package/dist/utils/ownership-validator.d.ts +6 -0
  101. package/dist/utils/ownership-validator.js +21 -0
  102. package/dist/waves.d.ts +21 -0
  103. package/dist/waves.js +146 -0
  104. package/package.json +120 -0
package/LICENSE ADDED
@@ -0,0 +1,65 @@
1
+ Business Source License 1.1
2
+
3
+ Licensor: Wundam LLC
4
+ Licensed Work: orchex
5
+ Additional Use Grant: You may use the Licensed Work for any purpose,
6
+ including production use, EXCEPT hosting, offering, or making available
7
+ the Licensed Work (or any substantial portion thereof) as a commercial
8
+ service that provides orchestration, parallel agent execution, or
9
+ substantially similar functionality (whether as a standalone product,
10
+ embedded in another product, or as part of a managed service platform).
11
+ Change Date: 2030-01-29
12
+ Change License: Apache License, Version 2.0
13
+
14
+ Notice
15
+
16
+ The Business Source License (this document, or the "License") is not an
17
+ Open Source license. However, the Licensed Work will eventually be made
18
+ available under an Open Source License, as stated in this License.
19
+
20
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights
21
+ Reserved. "Business Source License" is a trademark of MariaDB Corporation
22
+ Ab.
23
+
24
+ Terms
25
+
26
+ The Licensor hereby grants you the right to copy, modify, create
27
+ derivative works, redistribute, and make non-production use of the
28
+ Licensed Work. The Licensor may make an Additional Use Grant, above,
29
+ permitting limited production use.
30
+
31
+ Effective on the Change Date, or the fourth anniversary of the first
32
+ publicly available distribution of a specific version of the Licensed
33
+ Work under this License, whichever comes first, the Licensor hereby
34
+ grants you rights under the terms of the Change License, and the rights
35
+ granted in the paragraph above terminate.
36
+
37
+ If your use of the Licensed Work does not comply with the requirements
38
+ currently in effect as described in this License, you must purchase a
39
+ commercial license from the Licensor, its affiliated entities, or
40
+ authorized resellers, or you must refrain from using the Licensed Work.
41
+
42
+ All copies of the original and modified Licensed Work, and derivative
43
+ works of the Licensed Work, are subject to this License. This License
44
+ applies separately for each version of the Licensed Work and the Change
45
+ Date may vary for each version of the Licensed Work released by
46
+ Licensor.
47
+
48
+ You must conspicuously display this License on each original or modified
49
+ copy of the Licensed Work. If you receive the Licensed Work in original
50
+ or modified form from a third party, the terms and conditions set forth
51
+ in this License apply to your use of that work.
52
+
53
+ Any use of the Licensed Work in violation of this License will
54
+ automatically terminate your rights under this License for the current
55
+ and all other versions of the Licensed Work.
56
+
57
+ This License does not grant you any right in any trademark or logo of
58
+ Licensor or its affiliates (provided that you may use a trademark or
59
+ logo of Licensor as expressly required by this License).
60
+
61
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS
62
+ PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES
63
+ AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION)
64
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
65
+ NON-INFRINGEMENT, AND TITLE.
package/README.md ADDED
@@ -0,0 +1,332 @@
1
+ # orchex
2
+
3
+ **Turn a plan into parallel AI agents that can't break each other's code.**
4
+
5
+ The orchestration engine inside your AI coding assistant. Paste a plan doc, orchex splits it into parallel streams with file ownership enforcement, self-healing failures, and multi-LLM routing. Your AI assistant is the driver. Orchex is the engine.
6
+
7
+ ## Why Orchex
8
+
9
+ Your AI assistant does tasks one at a time. Orchex makes it do 10 at once — safely.
10
+
11
+ - **Parallel Execution** — Multiple streams run simultaneously in dependency-aware waves. 5-10x faster than serial prompting.
12
+ - **Ownership Enforcement** — Each stream can only modify files in its `owns` array. No two agents touch the same file. Zero conflicts.
13
+ - **`orchex learn`** — The magic command. Paste a markdown plan, get executable parallel streams with dependency inference and anti-pattern detection. No other tool does this.
14
+ - **Self-Healing** — 10 error categories with targeted fix streams. Not blind retry — categorized analysis with augmented instructions.
15
+ - **Multi-LLM** — OpenAI, Gemini, Claude, DeepSeek, Ollama. Route different orchestrations to different providers — use DeepSeek ($0.001/1K) for docs, Claude ($0.015/1K) for core logic.
16
+ - **BYOK** — Bring your own API key from any supported provider. You control costs.
17
+ - **Context Budget Intelligence** — Provider-aware limits with soft/hard enforcement and adaptive learning per stream category.
18
+ - **Team Collaboration** — Organization members see each other's orchestration runs. Shared dashboard with org switcher and access controls.
19
+ - **Observability** — Real-time stats: speedup multiplier, success rate, self-heal recoveries, time saved. Per-user dashboard with 30-day rolling metrics.
20
+
21
+ ## Prerequisites
22
+
23
+ - [Node.js](https://nodejs.org/) >= 18
24
+ - LLM API key (one of the following):
25
+ - `ANTHROPIC_API_KEY` for Anthropic Claude
26
+ - `OPENAI_API_KEY` for OpenAI (GPT-4, GPT-4.1)
27
+ - `GEMINI_API_KEY` for Google Gemini
28
+ - `DEEPSEEK_API_KEY` for DeepSeek (V3, Coder, Reasoner)
29
+ - Or configure Ollama for local models
30
+
31
+ ## Install
32
+
33
+ ```bash
34
+ npm install -g @wundam/orchex
35
+ ```
36
+
37
+ Or use directly:
38
+
39
+ ```bash
40
+ npx @wundam/orchex
41
+ ```
42
+
43
+ ## MCP Configuration
44
+
45
+ Add to your MCP config (e.g. project `.mcp.json`):
46
+
47
+ ```json
48
+ {
49
+ "mcpServers": {
50
+ "orchex": {
51
+ "command": "npx",
52
+ "args": ["@wundam/orchex"]
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ ### 1. Initialize an orchestration
61
+
62
+ ```
63
+ orchex.init({
64
+ feature: "user-authentication",
65
+ streams: {
66
+ types: {
67
+ name: "Define types",
68
+ deps: [],
69
+ owns: ["src/types.ts"],
70
+ reads: ["src/config.ts"],
71
+ plan: "Define TypeScript interfaces for auth",
72
+ setup: ["npm install"],
73
+ verify: ["npm test"]
74
+ },
75
+ api: {
76
+ name: "Build API",
77
+ deps: ["types"],
78
+ owns: ["src/api.ts"],
79
+ reads: ["src/types.ts"]
80
+ },
81
+ tests: {
82
+ name: "Write tests",
83
+ deps: ["types", "api"],
84
+ owns: ["tests/"],
85
+ verify: ["npm test"]
86
+ }
87
+ }
88
+ })
89
+ ```
90
+
91
+ ### 2. Execute
92
+
93
+ ```
94
+ orchex.execute({ mode: "auto" })
95
+ ```
96
+
97
+ Calculates waves from dependencies (topological sort), then for each wave:
98
+ 1. Runs **setup** commands for each stream
99
+ 2. Builds a **4-layer context prompt** (project, stream files, dependency artifacts, instructions)
100
+ 3. Calls the **LLM API** in parallel (one call per stream in the wave)
101
+ 4. Parses and **validates artifacts** from responses
102
+ 5. **Applies** file operations to the codebase
103
+ 6. Runs **verify** commands
104
+
105
+ Wave plan for the example above:
106
+ - **Wave 1:** `types` (no deps)
107
+ - **Wave 2:** `api` (depends on types)
108
+ - **Wave 3:** `tests` (depends on types + api)
109
+
110
+ Modes:
111
+ - `wave` (default) — execute one wave and return. Call repeatedly to step through.
112
+ - `auto` — execute all waves sequentially until done.
113
+ - `dry_run: true` — generate prompts without calling the LLM API.
114
+
115
+ ### 3. Check status
116
+
117
+ ```
118
+ orchex.status()
119
+ ```
120
+
121
+ ### 4. Complete
122
+
123
+ ```
124
+ orchex.complete({ archive: true })
125
+ ```
126
+
127
+ ## MCP Tools
128
+
129
+ | Tool | Description |
130
+ |------|-------------|
131
+ | `init` | Initialize orchestration with feature name and streams |
132
+ | `add_stream` | Add a stream to the active orchestration |
133
+ | `status` | Get orchestration progress and wave info |
134
+ | `execute` | Run the orchestration — calls LLM API, applies artifacts, verifies |
135
+ | `complete` | Mark streams done or archive orchestration |
136
+ | `learn` | Parse a planning document, generate atomic stream definitions, and surface prerequisites |
137
+ | `init-plan` | Generate an annotated plan template optimized for `orchex learn` |
138
+ | `recover` | Detect and recover stuck streams from mid-execution failures |
139
+ | `reload` | Restart the MCP server process (picks up config/code changes) |
140
+
141
+ ## Architecture
142
+
143
+ ```
144
+ orchex.execute()
145
+
146
+ For each wave (parallel streams within wave):
147
+
148
+ ├── 1. Resolve — load manifest, calculate waves, find target
149
+ ├── 2. Setup — run pre-execution commands
150
+ ├── 3. Context — build 4-layer prompt
151
+ │ ├── Project context (file tree, deps, config)
152
+ │ ├── Stream context (owned + read-only file contents)
153
+ │ ├── Dependency context (completed artifact summaries)
154
+ │ └── Instructions (artifact format, ownership rules)
155
+ ├── 4. Execute — call LLM API in parallel (Claude/OpenAI/Gemini/DeepSeek/Ollama)
156
+ ├── 5. Validate — parse orchex-artifact from response
157
+ ├── 6. Apply — write files to codebase (with ownership enforcement)
158
+ └── 7. Verify — run post-execution commands
159
+ ```
160
+
161
+ Streams can only modify files listed in their `owns` array. A file-based lock prevents concurrent `execute` calls.
162
+
163
+ ## Stream Definition
164
+
165
+ | Field | Type | Description |
166
+ |-------|------|-------------|
167
+ | `name` | `string` | Human-readable stream name |
168
+ | `deps` | `string[]` | Stream IDs this depends on (determines wave order) |
169
+ | `owns` | `string[]` | Files this stream can create/modify (ownership enforcement) |
170
+ | `reads` | `string[]` | Files this stream needs to read (included in context, not writable) |
171
+ | `plan` | `string` | Implementation instructions for the agent |
172
+ | `setup` | `string[]` | Shell commands to run before execution |
173
+ | `verify` | `string[]` | Shell commands to run after execution |
174
+ | `timeoutMs` | `number` | Per-stream timeout override in milliseconds (optional) |
175
+
176
+ ## Stream Slicing Best Practices
177
+
178
+ **One stream = one atomic deliverable.** If your stream description uses "and" between distinct concepts, split it.
179
+
180
+ | Pattern | Success | Why |
181
+ |---------|---------|-----|
182
+ | `docs-installation` (one installation guide) | ✅ | Single focused topic |
183
+ | `integration-claude-code` (one integration guide) | ✅ | Predictable structure |
184
+ | `unified-layout` (implementation + tests) | ✅ | Code + tests are one unit |
185
+ | `docs-structure` (5 different docs) | ❌ | Multiple distinct outputs |
186
+ | `tutorials-first` (setup + walkthrough + summary) | ❌ | Multiple conceptual sections |
187
+
188
+ **Slicing heuristics:**
189
+ - **`owns` > 4 distinct files** → Split (each file requiring different content should be separate)
190
+ - **`reads` > 4 files** → Split (high synthesis complexity = timeout risk)
191
+ - **Expected output > 6,000 tokens** → Split
192
+ - **Tutorials** → Section into intro/walkthrough/conclusion streams
193
+ - **Code implementation + its tests** → Keep together (they must match)
194
+ - **Templated repetition** → Can bundle (structurally identical outputs)
195
+
196
+ ## Context Budget Intelligence
197
+
198
+ Orchex Learn tracks context budget usage and adapts thresholds based on execution history.
199
+
200
+ ### Provider-Aware Limits
201
+
202
+ | Provider | Context Limit | Default Soft | Default Hard |
203
+ |----------|---------------|--------------|--------------|
204
+ | Anthropic | 200,000 | 140,000 | 180,000 |
205
+ | OpenAI | 128,000 | 89,600 | 115,200 |
206
+ | Gemini | 1,000,000 | 700,000 | 900,000 |
207
+ | DeepSeek | 128,000 | 89,600 | 115,200 |
208
+ | Ollama | 128,000 | 89,600 | 115,200 |
209
+
210
+ ### Budget Warnings
211
+
212
+ When a stream's estimated context exceeds limits, warnings appear in execution output:
213
+
214
+ ```json
215
+ {
216
+ "event": "budget_warning",
217
+ "streamId": "large-docs",
218
+ "violationType": "soft",
219
+ "estimatedTokens": 156000,
220
+ "budgetLimit": 140000
221
+ }
222
+ ```
223
+
224
+ ### Adaptive Learning
225
+
226
+ Thresholds improve as execution history accumulates:
227
+ - **Per-category limits** — Code streams vs. documentation vs. tutorials
228
+ - **Confidence levels** — Low (0-49 samples) → Medium (50-99) → High (100+)
229
+ - **Persisted learning** — Saved in `.orchex/learn/thresholds.json`
230
+
231
+ ### Stream Category Recommendations
232
+
233
+ | Category | Max Owns | Max Reads | Notes |
234
+ |----------|----------|-----------|-------|
235
+ | code | 4 | 4 | Implementation files |
236
+ | docs | 6 | 3 | Documentation pages |
237
+ | tutorial | 3 | 4 | Sectioned tutorials |
238
+ | test | 4 | 5 | Test files with fixtures |
239
+ | migration | 3 | 4 | Schema migrations |
240
+
241
+ ## Stream Validation
242
+
243
+ Orchex validates stream definitions during `init` and `add_stream`, detecting anti-patterns and suggesting improvements.
244
+
245
+ ### Quality Analysis
246
+
247
+ ```json
248
+ {
249
+ "qualityAnalysis": {
250
+ "overallScore": 85,
251
+ "issues": { "errors": 0, "warnings": 2, "info": 1 },
252
+ "problematicStreams": ["large-docs"],
253
+ "splitSuggestions": [{
254
+ "streamId": "large-docs",
255
+ "templateName": "Documentation Set",
256
+ "suggestedStreams": ["docs-overview", "docs-installation", "docs-quickstart"]
257
+ }]
258
+ }
259
+ }
260
+ ```
261
+
262
+ ### Anti-Patterns Detected
263
+
264
+ | Pattern | Severity | Description |
265
+ |---------|----------|-------------|
266
+ | High owns count | warning | Stream owns >4 files across multiple directories |
267
+ | High reads count | warning | Stream reads >4 files (synthesis complexity) |
268
+ | Compound plan | warning | Plan contains multiple "and" conjunctions |
269
+ | Empty plan | error | Stream has no plan description |
270
+ | No verification | info | Stream has no verify commands |
271
+
272
+ ### Template-Based Split Suggestions
273
+
274
+ When anti-patterns are detected, Orchex suggests splits based on known templates:
275
+ - **Documentation Set** — Split into overview, installation, quickstart, etc.
276
+ - **Code Feature** — Split into types, core, tests, docs
277
+ - **Migration** — Split into new implementation, migrate components, deprecate old
278
+ - **Tutorial** — Split into intro, steps, conclusion
279
+ - **API Reference** — Split by module
280
+
281
+ ### Automatic Splitting in `learn`
282
+
283
+ When `orchex learn` parses a markdown plan, it automatically splits deliverables with mixed concerns into focused sub-streams following `types → migrations → core → tests → docs` ordering. Each sub-stream gets relevant plan content and files for its concern. Dependencies chain sequentially: the first sub-stream inherits the parent's deps, and each subsequent sub-stream depends on the previous one. Cross-deliverable dependencies resolve to the `-core` sibling (the implementation stream) rather than scaffolding streams like `-types` or `-migrations`. Plan authors can use `- Read:` / `- Import:` markers alongside `- Create:` / `- Modify:` to declare read-only file dependencies.
284
+
285
+ ### Learn Pipeline Intelligence
286
+
287
+ The `learn` pipeline includes several quality improvements:
288
+
289
+ - **Import-based reads inference** — Parses `import`/`require()` from code blocks in plan documents and auto-adds referenced files to `reads`. Resolves relative imports when filename context is available.
290
+ - **Path validation** — Validates `owns`/`reads` paths against the filesystem when `projectDir` is available. Auto-corrects unambiguous mismatches (e.g., `tools.ts` → `src/tools.ts`) with visible warnings.
291
+ - **Cycle auto-resolution** — When two streams mutually read each other's owned files (context reads, not sequencing requirements), the false dependency cycle is automatically resolved. N-node file-ownership-only cycles are broken by removing the weakest edge. Cycles involving explicit or content-pattern dependencies are preserved and reported as errors.
292
+ - **Structured description extraction** — Complex sections (>3000 chars, >=3 children) get numbered task lists instead of truncated prose, ensuring all sub-sections are visible to the LLM.
293
+ - **Complexity warnings** — Flags deliverables with many sub-sections, suggesting YAML definitions or `deliverable_level: 3` for manual decomposition.
294
+
295
+ ## Development
296
+
297
+ ```bash
298
+ npm install
299
+ npm run build # TypeScript compilation
300
+ npm test # Run tests
301
+ npm run dev # Run with tsx (development)
302
+ ```
303
+
304
+ For local development, point `.mcp.json` to your local build:
305
+
306
+ ```json
307
+ {
308
+ "mcpServers": {
309
+ "orchex": {
310
+ "command": "node",
311
+ "args": ["./bin/orchex.js"],
312
+ "cwd": "/path/to/orchex"
313
+ }
314
+ }
315
+ }
316
+ ```
317
+
318
+ ## Pricing
319
+
320
+ | Tier | Price | What you get |
321
+ |---|---|---|
322
+ | **Local** | Free | Core MCP tools: 5 streams, 2 waves, single provider, BYOK. |
323
+ | **Cloud Trial** | $0 ($5 credit) | Full cloud features. 30-day credit, no credit card required. |
324
+ | **Pro** | $19/mo | 100 cloud runs/mo, 15 agents, 10 waves, 2 providers, `orchex learn`, full self-healing. |
325
+ | **Team** | $49/user/mo | 500 cloud runs/mo, 25 agents, 25 waves, 3 providers, shared orchestrations, team management. |
326
+ | **Enterprise** | Custom | Unlimited runs + waves, 50+ agents, all providers, self-hosted, SLA + dedicated support. |
327
+
328
+ 1 run = 1 orchestration. BYOK on all plans — you pay your own LLM API costs.
329
+
330
+ ## License
331
+
332
+ [BSL 1.1](LICENSE) — free to use for any purpose except hosting as a competing commercial orchestration service. Converts to Apache 2.0 on 2030-01-29.
package/bin/orchex.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/index.js';
@@ -0,0 +1,132 @@
1
+ import { type StreamArtifact, type FileOperation } from './types.js';
2
+ import { type OwnershipCheckOptions, type OwnershipCheckResult } from './ownership.js';
3
+ /**
4
+ * Read and validate a stream's artifact JSON file.
5
+ * Returns null if artifact doesn't exist.
6
+ */
7
+ export declare function readArtifact(projectDir: string, streamId: string): Promise<StreamArtifact | null>;
8
+ export interface SanityCheckResult {
9
+ passed: boolean;
10
+ violations: string[];
11
+ warnings: string[];
12
+ }
13
+ /**
14
+ * Validate artifact for degenerate outputs that are structurally valid
15
+ * but semantically broken (LLM repetition loops, truncation artifacts, etc.).
16
+ */
17
+ export declare function validateArtifactSanity(artifact: StreamArtifact): SanityCheckResult;
18
+ export interface ExtractionDiagnostic {
19
+ strategy: 'exact' | 'relaxed' | 'fence_recovery' | 'failed';
20
+ jsonRepaired: boolean;
21
+ rawLength: number;
22
+ error?: string;
23
+ }
24
+ export interface ExtractionResult {
25
+ artifact: StreamArtifact | null;
26
+ diagnostic: ExtractionDiagnostic;
27
+ }
28
+ /**
29
+ * Extract artifact JSON from an agent's response text with full diagnostics.
30
+ * Tries cascading strategies: exact → fence recovery.
31
+ */
32
+ export declare function extractArtifactWithDiagnostics(agentOutput: string): ExtractionResult;
33
+ /**
34
+ * Extract artifact JSON from an agent's response text.
35
+ * Backward-compatible wrapper — returns StreamArtifact | null.
36
+ */
37
+ export declare function extractArtifact(agentOutput: string): StreamArtifact | null;
38
+ /**
39
+ * Write an artifact JSON file for a stream.
40
+ * Used by the host session to save agent output.
41
+ */
42
+ export declare function writeArtifact(projectDir: string, streamId: string, artifact: StreamArtifact): Promise<string>;
43
+ export interface ApplyResult {
44
+ success: boolean;
45
+ streamId: string;
46
+ appliedOps: number;
47
+ error?: string;
48
+ errors?: string[];
49
+ /** Warnings about files that were allowed but notable (e.g., common files) */
50
+ warnings?: string[];
51
+ }
52
+ /**
53
+ * Check whether all file operations fall within the stream's owns patterns.
54
+ *
55
+ * Enhanced behavior (v3.1+):
56
+ * - Common project files (.gitignore, README.md, etc.) are allowed by default
57
+ * - Glob patterns supported in owns list
58
+ * - Security: path traversal and absolute paths always blocked
59
+ *
60
+ * @param operations - File operations to validate
61
+ * @param owns - Ownership patterns from stream definition
62
+ * @param options - Optional settings to control strictness
63
+ * @returns Array of violation messages (empty = all allowed)
64
+ */
65
+ export declare function checkOwnership(operations: FileOperation[], owns: string[], options?: OwnershipCheckOptions): string[];
66
+ /**
67
+ * Enhanced ownership check with detailed results.
68
+ * Returns violations, warnings, and allowed files separately.
69
+ */
70
+ export declare function checkOwnershipDetailed(operations: FileOperation[], owns: string[], options?: OwnershipCheckOptions): OwnershipCheckResult;
71
+ /**
72
+ * Apply a stream's artifact to the project codebase.
73
+ * Creates a backup before applying. Rolls back on error.
74
+ */
75
+ export declare function applyArtifact(projectDir: string, streamId: string, options?: {
76
+ dryRun?: boolean;
77
+ force?: boolean;
78
+ }): Promise<ApplyResult>;
79
+ /**
80
+ * Apply all artifacts for a set of stream IDs.
81
+ */
82
+ export declare function applyWaveArtifacts(projectDir: string, streamIds: string[], options?: {
83
+ dryRun?: boolean;
84
+ force?: boolean;
85
+ }): Promise<{
86
+ applied: string[];
87
+ failed: string[];
88
+ results: ApplyResult[];
89
+ }>;
90
+ /**
91
+ * Fuzzy edit replacement: tries line-by-line matching after trimming
92
+ * trailing whitespace from each line. Handles the most common LLM
93
+ * deviations: trailing spaces, \r\n vs \n, trailing blank lines.
94
+ *
95
+ * Returns the replaced content or null if no match found.
96
+ */
97
+ export declare function fuzzyReplace(content: string, oldContent: string, newContent: string): string | null;
98
+ interface BackupEntry {
99
+ path: string;
100
+ content: string;
101
+ }
102
+ export interface StreamBackup {
103
+ streamId: string;
104
+ entries: BackupEntry[];
105
+ createdFiles: string[];
106
+ }
107
+ /**
108
+ * Create backup of files that will be modified by operations.
109
+ * Public API — used by orchestrator for verify isolation.
110
+ */
111
+ export declare function createStreamBackup(projectDir: string, streamId: string, operations: FileOperation[]): Promise<StreamBackup>;
112
+ /**
113
+ * Revert a stream's changes using its backup.
114
+ * Restores modified files and removes created files.
115
+ */
116
+ export declare function revertStreamBackup(projectDir: string, backup: StreamBackup): Promise<void>;
117
+ /**
118
+ * Restore a stream's changes from its "modified state" backup.
119
+ * Used to re-apply changes after a temporary revert during verify isolation.
120
+ */
121
+ export declare function restoreStreamBackup(projectDir: string, backup: StreamBackup): Promise<void>;
122
+ /**
123
+ * Isolate which stream(s) caused a verify failure by temporarily
124
+ * reverting each stream's changes and re-running its verify commands.
125
+ *
126
+ * Returns a map of streamId → verdict:
127
+ * - 'guilty': reverting this stream made verify pass
128
+ * - 'innocent': reverting this stream didn't fix verify
129
+ * - 'unknown': couldn't determine (interaction between streams)
130
+ */
131
+ export declare function isolateVerifyFailure(projectDir: string, backups: StreamBackup[], failedVerifyMap: Map<string, string[]>): Promise<Map<string, 'guilty' | 'innocent' | 'unknown'>>;
132
+ export {};