@oxgeneral/orch 0.2.3 → 0.3.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 (145) hide show
  1. package/dist/App-TW35IULR.js +18 -0
  2. package/dist/agent-FRQKL7YI.js +9 -0
  3. package/dist/{orchestrator-VGYKSOZJ.js → chunk-2UC4SVJB.js} +236 -71
  4. package/dist/chunk-2UC4SVJB.js.map +1 -0
  5. package/dist/chunk-5AJ4LYO5.js +8 -0
  6. package/dist/{chunk-45K2XID7.js → chunk-6DWHQPTE.js} +2 -1
  7. package/dist/chunk-6DWHQPTE.js.map +1 -0
  8. package/dist/{chunk-POUC4CPC.js → chunk-6MJ7V6VY.js} +2 -2
  9. package/dist/{chunk-HNKJ4IF7.js → chunk-B4JQM4NU.js} +34 -10
  10. package/dist/chunk-B4JQM4NU.js.map +1 -0
  11. package/dist/{chunk-6HENRUYZ.js → chunk-CDFA4IIQ.js} +2 -2
  12. package/dist/chunk-CHRW4CLD.js +2 -0
  13. package/dist/{chunk-ZU6AY2VU.js → chunk-GZ2Q56YZ.js} +2 -2
  14. package/dist/chunk-HMMPM7MF.js +3 -0
  15. package/dist/{chunk-AELEEEV3.js → chunk-HSBYJ5C5.js} +27 -7
  16. package/dist/chunk-HXOMNULD.js +2 -0
  17. package/dist/{chunk-O5AO5QIR.js → chunk-IQXRQBUK.js} +9 -2
  18. package/dist/chunk-IQXRQBUK.js.map +1 -0
  19. package/dist/chunk-L26TK7Y5.js +2 -0
  20. package/dist/chunk-L3FYR45M.js +2 -0
  21. package/dist/chunk-LXNRCJ22.js +2 -0
  22. package/dist/{chunk-TX7WOFCW.js → chunk-MGFMVPRD.js} +4 -7
  23. package/dist/chunk-MGFMVPRD.js.map +1 -0
  24. package/dist/chunk-MNXU3KCD.js +2 -0
  25. package/dist/{chunk-CHIP7O6V.js → chunk-O2MSGW3V.js} +3 -1
  26. package/dist/chunk-O2MSGW3V.js.map +1 -0
  27. package/dist/chunk-PJ5DKXGR.js +2 -0
  28. package/dist/{chunk-VTA74YWX.js → chunk-QEEM67OA.js} +11 -17
  29. package/dist/chunk-QEEM67OA.js.map +1 -0
  30. package/dist/chunk-UMZEA3JT.js +5 -0
  31. package/dist/{shell-OGTSH4RJ.js → chunk-UW6GUUE6.js} +3 -3
  32. package/dist/chunk-XDVMX2FO.js +8 -0
  33. package/dist/chunk-XDVMX2FO.js.map +1 -0
  34. package/dist/chunk-ZA5Z33GO.js +11 -0
  35. package/dist/claude-E36EGXUV.js +2 -0
  36. package/dist/{chunk-IRN2U2NE.js → claude-RIB3RQS5.js} +5 -2
  37. package/dist/claude-RIB3RQS5.js.map +1 -0
  38. package/dist/cli.js +1 -199
  39. package/dist/clipboard-service-PDTSZIR5.js +25 -0
  40. package/dist/codex-OTZKVESD.js +2 -0
  41. package/dist/{codex-U7LTJTX6.js → codex-VBUSA2GJ.js} +5 -3
  42. package/dist/codex-VBUSA2GJ.js.map +1 -0
  43. package/dist/config-CCSS2P7R.js +2 -0
  44. package/dist/container-OIXLFSX2.js +6 -0
  45. package/dist/context-GSMQHQES.js +7 -0
  46. package/dist/cursor-3DJA6LWS.js +2 -0
  47. package/dist/{cursor-3DI5GKRF.js → cursor-4QIOTDBW.js} +5 -3
  48. package/dist/cursor-4QIOTDBW.js.map +1 -0
  49. package/dist/doctor-KBK5JZBZ.js +2 -0
  50. package/dist/doctor-service-F2SXDWHS.js +91 -0
  51. package/dist/doctor-service-F2SXDWHS.js.map +1 -0
  52. package/dist/doctor-service-PB7YBH3F.js +2 -0
  53. package/dist/goal-RFKFPR7M.js +8 -0
  54. package/dist/index.d.ts +124 -46
  55. package/dist/index.js +1817 -5
  56. package/dist/index.js.map +1 -1
  57. package/dist/init-WRDFAFS2.js +53 -0
  58. package/dist/logs-5QHJWMEG.js +12 -0
  59. package/dist/msg-4SCLBO4K.js +9 -0
  60. package/dist/orchestrator-FGGXK3N3.js +5 -0
  61. package/dist/{orchestrator-TAFBYQQ5.js.map → orchestrator-FGGXK3N3.js.map} +1 -1
  62. package/dist/orchestrator-R7IWZUT6.js +13 -0
  63. package/dist/process-manager-33H27MQF.js +2 -0
  64. package/dist/process-manager-A36Y7LHP.js +3 -0
  65. package/dist/{process-manager-TLZOTO4Y.js.map → process-manager-A36Y7LHP.js.map} +1 -1
  66. package/dist/registry-BO2PPRNG.js +2 -0
  67. package/dist/registry-JXXRLJ5J.js +3 -0
  68. package/dist/{registry-UQAHK77P.js.map → registry-JXXRLJ5J.js.map} +1 -1
  69. package/dist/run-HSHRELOP.js +3 -0
  70. package/dist/shell-EOJBDWTH.js +2 -0
  71. package/dist/{chunk-CIIE6LNG.js → shell-IH2MMTVP.js} +3 -2
  72. package/dist/shell-IH2MMTVP.js.map +1 -0
  73. package/dist/status-DLBNWSWM.js +2 -0
  74. package/dist/task-J6ZN7ALI.js +20 -0
  75. package/dist/team-MSIBKOQC.js +4 -0
  76. package/dist/template-engine-MFL5B677.js +3 -0
  77. package/dist/{template-engine-322SCRR6.js.map → template-engine-MFL5B677.js.map} +1 -1
  78. package/dist/template-engine-ONIDVD4F.js +2 -0
  79. package/dist/tui-G4XUFAIP.js +2 -0
  80. package/dist/update-PC2ENCKU.js +2 -0
  81. package/dist/update-check-HGMBDYHL.js +2 -0
  82. package/dist/workspace-manager-KOOYTO7E.js +3 -0
  83. package/dist/{workspace-manager-47KI7B27.js → workspace-manager-T6AXG7XL.js} +40 -3
  84. package/dist/workspace-manager-T6AXG7XL.js.map +1 -0
  85. package/package.json +2 -1
  86. package/readme.md +5 -4
  87. package/scripts/benchmark.ts +304 -0
  88. package/dist/App-KDZSTAMR.js +0 -4864
  89. package/dist/agent-V5M2C3OC.js +0 -157
  90. package/dist/chunk-2B32FPEB.js +0 -11
  91. package/dist/chunk-2B32FPEB.js.map +0 -1
  92. package/dist/chunk-33QNTNR6.js +0 -46
  93. package/dist/chunk-6GFVB6EK.js +0 -101
  94. package/dist/chunk-6HENRUYZ.js.map +0 -1
  95. package/dist/chunk-AELEEEV3.js.map +0 -1
  96. package/dist/chunk-E3TCKHU6.js +0 -13
  97. package/dist/chunk-E3TCKHU6.js.map +0 -1
  98. package/dist/chunk-ED47GL3F.js +0 -29
  99. package/dist/chunk-HXYAZGLP.js +0 -15
  100. package/dist/chunk-I5WEMARW.js +0 -166
  101. package/dist/chunk-IZYSGYXG.js +0 -2
  102. package/dist/chunk-IZYSGYXG.js.map +0 -1
  103. package/dist/chunk-P6ATSXGL.js +0 -107
  104. package/dist/chunk-PBFE5V3G.js +0 -2
  105. package/dist/chunk-PBFE5V3G.js.map +0 -1
  106. package/dist/chunk-PNE6LQRF.js +0 -5
  107. package/dist/chunk-POUC4CPC.js.map +0 -1
  108. package/dist/chunk-XI4TU6VU.js +0 -50
  109. package/dist/chunk-ZU6AY2VU.js.map +0 -1
  110. package/dist/claude-GH6P2DC5.js +0 -4
  111. package/dist/claude-S47YTIHU.js +0 -2
  112. package/dist/claude-S47YTIHU.js.map +0 -1
  113. package/dist/codex-2CH57B7G.js +0 -2
  114. package/dist/codex-2CH57B7G.js.map +0 -1
  115. package/dist/config-LJFM55LN.js +0 -75
  116. package/dist/container-JV7TAUP5.js +0 -1532
  117. package/dist/context-EPSDCJTU.js +0 -83
  118. package/dist/cursor-QFUNKPCQ.js +0 -2
  119. package/dist/cursor-QFUNKPCQ.js.map +0 -1
  120. package/dist/doctor-IO4PV4D6.js +0 -67
  121. package/dist/doctor-service-A34DHPKI.js +0 -2
  122. package/dist/doctor-service-NTWBWOM2.js +0 -2
  123. package/dist/doctor-service-NTWBWOM2.js.map +0 -1
  124. package/dist/goal-I56QP7HS.js +0 -110
  125. package/dist/init-BE5VKWOM.js +0 -149
  126. package/dist/logs-IAUAS5TX.js +0 -207
  127. package/dist/msg-SQWQLJP6.js +0 -95
  128. package/dist/orchestrator-TAFBYQQ5.js +0 -2
  129. package/dist/process-manager-HUVNAPQV.js +0 -2
  130. package/dist/process-manager-TLZOTO4Y.js +0 -2
  131. package/dist/registry-PQWRVNF2.js +0 -2
  132. package/dist/registry-UQAHK77P.js +0 -2
  133. package/dist/run-PSZURVVL.js +0 -95
  134. package/dist/shell-5ZNXFGXV.js +0 -3
  135. package/dist/shell-OGTSH4RJ.js.map +0 -1
  136. package/dist/status-DTF7D3DV.js +0 -56
  137. package/dist/task-5OJTXW27.js +0 -209
  138. package/dist/team-AISPLEJB.js +0 -97
  139. package/dist/template-engine-322SCRR6.js +0 -2
  140. package/dist/template-engine-3CDRZNMJ.js +0 -3
  141. package/dist/tui-XDJE3IUA.js +0 -225
  142. package/dist/update-72GZMF65.js +0 -64
  143. package/dist/update-check-4RV7Z6WT.js +0 -2
  144. package/dist/workspace-manager-7M46ESUL.js +0 -2
  145. package/dist/workspace-manager-7M46ESUL.js.map +0 -1
@@ -0,0 +1,304 @@
1
+ #!/usr/bin/env tsx
2
+ /**
3
+ * Benchmark script for AgentsOrchestryCLI.
4
+ *
5
+ * Measures CLI startup, build time, and test suite duration.
6
+ * Results saved to .orchestry/benchmarks/<timestamp>.json.
7
+ *
8
+ * Usage: npx tsx scripts/benchmark.ts
9
+ */
10
+
11
+ import { execSync } from 'node:child_process';
12
+ import { mkdirSync, writeFileSync } from 'node:fs';
13
+ import { join } from 'node:path';
14
+
15
+ // ── Targets ──────────────────────────────────────────────────
16
+
17
+ const TARGETS: Record<string, number> = {
18
+ 'cli-help': 50,
19
+ 'cli-task-list': 100,
20
+ 'build': 1500,
21
+ 'test-suite': 12000,
22
+ 'tick-cycle': 50,
23
+ };
24
+
25
+ // ── Types ────────────────────────────────────────────────────
26
+
27
+ interface BenchmarkResult {
28
+ name: string;
29
+ runs: number[];
30
+ median: number;
31
+ min: number;
32
+ max: number;
33
+ target: number;
34
+ pass: boolean;
35
+ }
36
+
37
+ interface BenchmarkReport {
38
+ timestamp: string;
39
+ node: string;
40
+ platform: string;
41
+ results: BenchmarkResult[];
42
+ }
43
+
44
+ // ── Helpers ──────────────────────────────────────────────────
45
+
46
+ function median(values: number[]): number {
47
+ const sorted = [...values].sort((a, b) => a - b);
48
+ const mid = Math.floor(sorted.length / 2);
49
+ return sorted.length % 2 === 0
50
+ ? (sorted[mid - 1]! + sorted[mid]!) / 2
51
+ : sorted[mid]!;
52
+ }
53
+
54
+ function measure(cmd: string): number {
55
+ const start = performance.now();
56
+ execSync(cmd, { stdio: 'pipe', cwd: process.cwd() });
57
+ return Math.round(performance.now() - start);
58
+ }
59
+
60
+ function measureN(cmd: string, n: number): number[] {
61
+ const runs: number[] = [];
62
+ for (let i = 0; i < n; i++) {
63
+ runs.push(measure(cmd));
64
+ }
65
+ return runs;
66
+ }
67
+
68
+ function toBenchmarkResult(name: string, runs: number[], target: number): BenchmarkResult {
69
+ const med = median(runs);
70
+ return {
71
+ name,
72
+ runs,
73
+ median: med,
74
+ min: Math.min(...runs),
75
+ max: Math.max(...runs),
76
+ target,
77
+ pass: med <= target,
78
+ };
79
+ }
80
+
81
+ // ── Benchmarks ───────────────────────────────────────────────
82
+
83
+ function benchCliHelp(): BenchmarkResult {
84
+ const runs = measureN('node dist/cli.js --help', 3);
85
+ return toBenchmarkResult('cli-help', runs, TARGETS['cli-help']!);
86
+ }
87
+
88
+ function benchCliTaskList(): BenchmarkResult {
89
+ const runs = measureN('node dist/cli.js task list', 3);
90
+ return toBenchmarkResult('cli-task-list', runs, TARGETS['cli-task-list']!);
91
+ }
92
+
93
+ function benchBuild(): BenchmarkResult {
94
+ const runs = [measure('npm run build')];
95
+ return toBenchmarkResult('build', runs, TARGETS['build']!);
96
+ }
97
+
98
+ function benchTestSuite(): BenchmarkResult {
99
+ const runs = [measure('npx vitest run')];
100
+ return toBenchmarkResult('test-suite', runs, TARGETS['test-suite']!);
101
+ }
102
+
103
+ async function benchTickCycle(): Promise<BenchmarkResult> {
104
+ // Dynamic imports — only resolved when running via tsx
105
+ const { EventBus } = await import('../src/application/event-bus.js');
106
+ const { TaskService } = await import('../src/application/task-service.js');
107
+ const { AgentService } = await import('../src/application/agent-service.js');
108
+ const { RunService } = await import('../src/application/run-service.js');
109
+ const { AdapterRegistry } = await import('../src/infrastructure/adapters/registry.js');
110
+ const { Orchestrator } = await import('../src/application/orchestrator.js');
111
+ const { DEFAULT_CONFIG } = await import('../src/domain/config.js');
112
+ const { DEFAULT_STATE } = await import('../src/domain/state.js');
113
+
114
+ const TICK_RUNS = 100;
115
+ const config = { ...DEFAULT_CONFIG, scheduling: { ...DEFAULT_CONFIG.scheduling, poll_interval_ms: 999_999 } };
116
+
117
+ // Minimal in-memory mock stores
118
+ const taskStore = {
119
+ list: async () => Array.from({ length: 10 }, (_, i) => ({
120
+ id: `tsk_${i}`, title: `T${i}`, description: '', status: 'todo' as const,
121
+ priority: 2, labels: [], depends_on: [], created_at: '2025-01-01T00:00:00Z',
122
+ updated_at: '2025-01-01T00:00:00Z', attempts: 0, max_attempts: 3,
123
+ })),
124
+ get: async () => null,
125
+ save: async () => {},
126
+ delete: async () => {},
127
+ };
128
+
129
+ const agentStore = {
130
+ list: async () => Array.from({ length: 3 }, (_, i) => ({
131
+ id: `agt_${i}`, name: `A${i}`, adapter: 'shell', status: 'idle' as const,
132
+ config: { approval_policy: 'auto' as const, max_turns: 50, timeout_ms: 3_600_000, stall_timeout_ms: 300_000 },
133
+ stats: { tasks_completed: 0, tasks_failed: 0, total_runs: 0, total_runtime_ms: 0 },
134
+ })),
135
+ get: async () => null,
136
+ getByName: async () => null,
137
+ save: async () => {},
138
+ delete: async () => {},
139
+ };
140
+
141
+ const runStore = {
142
+ save: async () => {},
143
+ get: async () => null,
144
+ listForTask: async () => [],
145
+ listForAgent: async () => [],
146
+ appendEvent: async () => {},
147
+ readEvents: async () => [],
148
+ readEventsTail: async () => [],
149
+ streamEvents: async function* () {},
150
+ };
151
+
152
+ let state = structuredClone(DEFAULT_STATE);
153
+ const stateStore = {
154
+ read: async () => structuredClone(state),
155
+ write: async (s: typeof state) => { state = structuredClone(s); },
156
+ };
157
+
158
+ const eventBus = new EventBus();
159
+ const processManager = {
160
+ isAlive: () => false,
161
+ kill: () => {},
162
+ killWithGrace: async () => {},
163
+ spawn: () => ({ process: {} as ReturnType<typeof import('node:child_process').spawn>, pid: 1 }),
164
+ };
165
+
166
+ const workspaceManager = {
167
+ prepare: async () => ({ path: '/tmp/ws' }),
168
+ mergeBack: async () => ({ success: true as const }),
169
+ cleanup: async () => {},
170
+ validate: () => {},
171
+ };
172
+
173
+ const templateEngine = { render: async () => 'prompt' };
174
+ const contextStore = {
175
+ get: async () => null, set: async () => {}, delete: async () => {},
176
+ list: async () => [], getAll: async () => ({}),
177
+ };
178
+
179
+ const deps = {
180
+ taskStore, agentStore, runStore, stateStore,
181
+ adapterRegistry: new AdapterRegistry(),
182
+ workspaceManager, templateEngine, processManager,
183
+ eventBus,
184
+ taskService: new TaskService(taskStore, eventBus, config),
185
+ agentService: new AgentService(agentStore, stateStore, eventBus, config),
186
+ runService: new RunService(runStore, eventBus),
187
+ contextStore,
188
+ config,
189
+ projectRoot: '/tmp/bench',
190
+ lockPath: '/tmp/bench/.orchestry/lock',
191
+ };
192
+
193
+ const orch = new Orchestrator(deps);
194
+
195
+ // Warm up: force internal state load
196
+ // Access private tick via bracket notation for benchmark purposes
197
+ const orchAny = orch as unknown as { tick(): Promise<void>; lockAcquired: boolean; state: typeof state };
198
+ orchAny.lockAcquired = true;
199
+ orchAny.state = structuredClone(DEFAULT_STATE);
200
+
201
+ const runs: number[] = [];
202
+ for (let i = 0; i < TICK_RUNS; i++) {
203
+ const start = performance.now();
204
+ await orchAny.tick();
205
+ runs.push(Math.round((performance.now() - start) * 100) / 100);
206
+ }
207
+
208
+ return toBenchmarkResult('tick-cycle', runs.map(Math.round), TARGETS['tick-cycle']!);
209
+ }
210
+
211
+ // ── Output ───────────────────────────────────────────────────
212
+
213
+ function printTable(results: BenchmarkResult[]): void {
214
+ const nameW = 16;
215
+ const colW = 10;
216
+
217
+ const header = [
218
+ 'Benchmark'.padEnd(nameW),
219
+ 'Median'.padStart(colW),
220
+ 'Min'.padStart(colW),
221
+ 'Max'.padStart(colW),
222
+ 'Target'.padStart(colW),
223
+ 'Status'.padStart(colW),
224
+ ].join(' ');
225
+
226
+ const sep = '─'.repeat(header.length);
227
+
228
+ console.log(`\n${sep}`);
229
+ console.log(header);
230
+ console.log(sep);
231
+
232
+ for (const r of results) {
233
+ const status = r.pass ? 'PASS' : r.median <= r.target * 1.2 ? 'NEAR PASS' : 'FAIL';
234
+ const line = [
235
+ r.name.padEnd(nameW),
236
+ `${r.median}ms`.padStart(colW),
237
+ `${r.min}ms`.padStart(colW),
238
+ `${r.max}ms`.padStart(colW),
239
+ `${r.target}ms`.padStart(colW),
240
+ status.padStart(colW),
241
+ ].join(' ');
242
+ console.log(line);
243
+ }
244
+
245
+ console.log(sep);
246
+
247
+ const allPass = results.every((r) => r.pass);
248
+ console.log(allPass ? '\nAll benchmarks PASS' : '\nSome benchmarks FAIL');
249
+ }
250
+
251
+ function saveReport(report: BenchmarkReport): string {
252
+ const dir = join(process.cwd(), '.orchestry', 'benchmarks');
253
+ mkdirSync(dir, { recursive: true });
254
+ const filename = `${report.timestamp.replace(/[:.]/g, '-')}.json`;
255
+ const filepath = join(dir, filename);
256
+ writeFileSync(filepath, JSON.stringify(report, null, 2) + '\n');
257
+ return filepath;
258
+ }
259
+
260
+ // ── Main ─────────────────────────────────────────────────────
261
+
262
+ async function main(): Promise<void> {
263
+ console.log('Running benchmarks...\n');
264
+
265
+ // Ensure build exists for CLI benchmarks
266
+ try {
267
+ execSync('node dist/cli.js --version', { stdio: 'pipe' });
268
+ } catch {
269
+ console.log('Building first (dist/ not ready)...');
270
+ execSync('npm run build', { stdio: 'inherit' });
271
+ console.log('');
272
+ }
273
+
274
+ const results: BenchmarkResult[] = [];
275
+
276
+ console.log('[1/5] CLI --help (3 runs)');
277
+ results.push(benchCliHelp());
278
+
279
+ console.log('[2/5] CLI task list (3 runs)');
280
+ results.push(benchCliTaskList());
281
+
282
+ console.log('[3/5] Build');
283
+ results.push(benchBuild());
284
+
285
+ console.log('[4/5] Test suite');
286
+ results.push(benchTestSuite());
287
+
288
+ console.log('[5/5] Tick cycle (100 runs)');
289
+ results.push(await benchTickCycle());
290
+
291
+ const report: BenchmarkReport = {
292
+ timestamp: new Date().toISOString(),
293
+ node: process.version,
294
+ platform: `${process.platform}-${process.arch}`,
295
+ results,
296
+ };
297
+
298
+ printTable(results);
299
+
300
+ const filepath = saveReport(report);
301
+ console.log(`\nSaved: ${filepath}`);
302
+ }
303
+
304
+ main();