agent-orchestration 0.5.0 → 0.6.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 (120) hide show
  1. package/.cursor/rules/orchestrator-auto.mdc +2 -0
  2. package/.cursor/rules/orchestrator-main.mdc +37 -7
  3. package/.cursor/rules/orchestrator-sub.mdc +89 -27
  4. package/README.md +278 -66
  5. package/dist/bin/cli.d.ts +1 -0
  6. package/dist/bin/cli.d.ts.map +1 -1
  7. package/dist/bin/cli.js +54 -157
  8. package/dist/bin/cli.js.map +1 -1
  9. package/dist/bin/cursorCommands.d.ts +3 -0
  10. package/dist/bin/cursorCommands.d.ts.map +1 -0
  11. package/dist/bin/cursorCommands.js +330 -0
  12. package/dist/bin/cursorCommands.js.map +1 -0
  13. package/dist/database.d.ts +32 -1
  14. package/dist/database.d.ts.map +1 -1
  15. package/dist/database.js +105 -5
  16. package/dist/database.js.map +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +6 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/models.d.ts +59 -0
  21. package/dist/models.d.ts.map +1 -1
  22. package/dist/models.js +69 -0
  23. package/dist/models.js.map +1 -1
  24. package/dist/providers/cursor.d.ts +14 -0
  25. package/dist/providers/cursor.d.ts.map +1 -0
  26. package/dist/providers/cursor.js +203 -0
  27. package/dist/providers/cursor.js.map +1 -0
  28. package/dist/providers/types.d.ts +60 -0
  29. package/dist/providers/types.d.ts.map +1 -0
  30. package/dist/providers/types.js +2 -0
  31. package/dist/providers/types.js.map +1 -0
  32. package/dist/tools/agent.d.ts.map +1 -1
  33. package/dist/tools/agent.js +5 -0
  34. package/dist/tools/agent.js.map +1 -1
  35. package/dist/tools/coordination.d.ts.map +1 -1
  36. package/dist/tools/coordination.js +47 -0
  37. package/dist/tools/coordination.js.map +1 -1
  38. package/dist/tools/index.d.ts +3 -0
  39. package/dist/tools/index.d.ts.map +1 -1
  40. package/dist/tools/index.js +3 -0
  41. package/dist/tools/index.js.map +1 -1
  42. package/dist/tools/memory.d.ts.map +1 -1
  43. package/dist/tools/memory.js +6 -1
  44. package/dist/tools/memory.js.map +1 -1
  45. package/dist/tools/provider.d.ts +3 -0
  46. package/dist/tools/provider.d.ts.map +1 -0
  47. package/dist/tools/provider.js +403 -0
  48. package/dist/tools/provider.js.map +1 -0
  49. package/dist/tools/proxy.d.ts +6 -0
  50. package/dist/tools/proxy.d.ts.map +1 -0
  51. package/dist/tools/proxy.js +107 -0
  52. package/dist/tools/proxy.js.map +1 -0
  53. package/dist/tools/research.d.ts +9 -0
  54. package/dist/tools/research.d.ts.map +1 -0
  55. package/dist/tools/research.js +182 -0
  56. package/dist/tools/research.js.map +1 -0
  57. package/dist/tools/task.d.ts.map +1 -1
  58. package/dist/tools/task.js +98 -9
  59. package/dist/tools/task.js.map +1 -1
  60. package/dist/tools/utility.d.ts.map +1 -1
  61. package/dist/tools/utility.js +85 -16
  62. package/dist/tools/utility.js.map +1 -1
  63. package/dist/utils/autoDocumentation.d.ts +8 -0
  64. package/dist/utils/autoDocumentation.d.ts.map +1 -0
  65. package/dist/utils/autoDocumentation.js +140 -0
  66. package/dist/utils/autoDocumentation.js.map +1 -0
  67. package/dist/utils/autoDocumentation.test.d.ts +2 -0
  68. package/dist/utils/autoDocumentation.test.d.ts.map +1 -0
  69. package/dist/utils/autoDocumentation.test.js +47 -0
  70. package/dist/utils/autoDocumentation.test.js.map +1 -0
  71. package/dist/utils/contextSync.d.ts.map +1 -1
  72. package/dist/utils/contextSync.js +21 -1
  73. package/dist/utils/contextSync.js.map +1 -1
  74. package/dist/utils/cursorCli.d.ts +46 -0
  75. package/dist/utils/cursorCli.d.ts.map +1 -0
  76. package/dist/utils/cursorCli.js +176 -0
  77. package/dist/utils/cursorCli.js.map +1 -0
  78. package/dist/utils/cursorCli.test.d.ts +2 -0
  79. package/dist/utils/cursorCli.test.d.ts.map +1 -0
  80. package/dist/utils/cursorCli.test.js +134 -0
  81. package/dist/utils/cursorCli.test.js.map +1 -0
  82. package/dist/utils/delegatedTaskRuntime.d.ts +45 -0
  83. package/dist/utils/delegatedTaskRuntime.d.ts.map +1 -0
  84. package/dist/utils/delegatedTaskRuntime.js +147 -0
  85. package/dist/utils/delegatedTaskRuntime.js.map +1 -0
  86. package/dist/utils/delegationKnowledge.d.ts +51 -0
  87. package/dist/utils/delegationKnowledge.d.ts.map +1 -0
  88. package/dist/utils/delegationKnowledge.js +197 -0
  89. package/dist/utils/delegationKnowledge.js.map +1 -0
  90. package/dist/utils/delegationRecovery.d.ts +17 -0
  91. package/dist/utils/delegationRecovery.d.ts.map +1 -0
  92. package/dist/utils/delegationRecovery.js +63 -0
  93. package/dist/utils/delegationRecovery.js.map +1 -0
  94. package/dist/utils/delegationRecovery.test.d.ts +2 -0
  95. package/dist/utils/delegationRecovery.test.d.ts.map +1 -0
  96. package/dist/utils/delegationRecovery.test.js +42 -0
  97. package/dist/utils/delegationRecovery.test.js.map +1 -0
  98. package/dist/utils/orchestratorConfig.d.ts +19 -0
  99. package/dist/utils/orchestratorConfig.d.ts.map +1 -0
  100. package/dist/utils/orchestratorConfig.js +38 -0
  101. package/dist/utils/orchestratorConfig.js.map +1 -0
  102. package/dist/utils/subprocess.d.ts +27 -0
  103. package/dist/utils/subprocess.d.ts.map +1 -0
  104. package/dist/utils/subprocess.js +84 -0
  105. package/dist/utils/subprocess.js.map +1 -0
  106. package/package.json +17 -5
  107. package/templates/AGENTS.md +164 -0
  108. package/activeContext.md +0 -37
  109. package/src/bin/cli.ts +0 -430
  110. package/src/database.ts +0 -764
  111. package/src/index.ts +0 -71
  112. package/src/models.ts +0 -226
  113. package/src/tools/agent.ts +0 -241
  114. package/src/tools/coordination.ts +0 -152
  115. package/src/tools/index.ts +0 -9
  116. package/src/tools/memory.ts +0 -150
  117. package/src/tools/task.ts +0 -334
  118. package/src/tools/utility.ts +0 -202
  119. package/src/utils/contextSync.ts +0 -144
  120. package/tsconfig.json +0 -20
@@ -0,0 +1,63 @@
1
+ export function evaluateDelegationHealth(params) {
2
+ const { metadata, isRunning, exitCode, staleAfterMs } = params;
3
+ const now = params.now ?? new Date();
4
+ if (exitCode !== undefined) {
5
+ if (exitCode === 0) {
6
+ return {
7
+ state: 'completed',
8
+ recoverable: false,
9
+ exitCode,
10
+ hints: ['Use `cursor_resume_task` to inspect the last session if needed.'],
11
+ };
12
+ }
13
+ return {
14
+ state: 'failed',
15
+ recoverable: true,
16
+ exitCode,
17
+ reason: `Cursor run exited with code ${exitCode}.`,
18
+ hints: [
19
+ 'Run `cursor_sync_task` to capture the latest output and recovery hints.',
20
+ 'Inspect the provider log for the failure details.',
21
+ 'Use `cursor_recover_task` to relaunch with the latest shared context.',
22
+ ],
23
+ };
24
+ }
25
+ if (isRunning) {
26
+ return {
27
+ state: 'healthy',
28
+ recoverable: false,
29
+ hints: ['The delegated process is still running. Use `cursor_sync_task` for a fresh snapshot.'],
30
+ };
31
+ }
32
+ const referenceTime = metadata.providerLastSyncAt ?? metadata.providerLaunchedAt;
33
+ if (referenceTime) {
34
+ const ageMs = now.getTime() - new Date(referenceTime).getTime();
35
+ if (ageMs >= staleAfterMs) {
36
+ return {
37
+ state: 'stale',
38
+ recoverable: true,
39
+ reason: `No running process or exit code was found after ${Math.round(ageMs / 1000)}s.`,
40
+ hints: [
41
+ 'The delegated process appears stale or crashed without a clean exit.',
42
+ 'Use `cursor_recover_task` to relaunch with the latest shared knowledge.',
43
+ 'Record a `cursor_handoff_task` note if a human diagnosis is needed first.',
44
+ ],
45
+ };
46
+ }
47
+ }
48
+ return {
49
+ state: 'unknown',
50
+ recoverable: true,
51
+ reason: 'The delegated process is not running and no exit code was captured yet.',
52
+ hints: [
53
+ 'Run `cursor_sync_task` again after a short wait.',
54
+ 'Use `cursor_recover_task` if the process does not come back.',
55
+ ],
56
+ };
57
+ }
58
+ export function getRecoveryDisplayLine(metadata) {
59
+ const state = metadata.providerRecoveryState ?? 'unknown';
60
+ const recoverable = metadata.providerRecoverable ? 'recoverable' : 'stable';
61
+ return `${state} (${recoverable})`;
62
+ }
63
+ //# sourceMappingURL=delegationRecovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegationRecovery.js","sourceRoot":"","sources":["../../src/utils/delegationRecovery.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,wBAAwB,CAAC,MAMxC;IACC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;IAErC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO;gBACL,KAAK,EAAE,WAAW;gBAClB,WAAW,EAAE,KAAK;gBAClB,QAAQ;gBACR,KAAK,EAAE,CAAC,iEAAiE,CAAC;aAC3E,CAAC;QACJ,CAAC;QAED,OAAO;YACL,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,IAAI;YACjB,QAAQ;YACR,MAAM,EAAE,+BAA+B,QAAQ,GAAG;YAClD,KAAK,EAAE;gBACL,yEAAyE;gBACzE,mDAAmD;gBACnD,uEAAuE;aACxE;SACF,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,KAAK;YAClB,KAAK,EAAE,CAAC,sFAAsF,CAAC;SAChG,CAAC;IACJ,CAAC;IAED,MAAM,aAAa,GAAG,QAAQ,CAAC,kBAAkB,IAAI,QAAQ,CAAC,kBAAkB,CAAC;IACjF,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC;QAChE,IAAI,KAAK,IAAI,YAAY,EAAE,CAAC;YAC1B,OAAO;gBACL,KAAK,EAAE,OAAO;gBACd,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,mDAAmD,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI;gBACvF,KAAK,EAAE;oBACL,sEAAsE;oBACtE,yEAAyE;oBACzE,2EAA2E;iBAC5E;aACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,IAAI;QACjB,MAAM,EAAE,yEAAyE;QACjF,KAAK,EAAE;YACL,kDAAkD;YAClD,8DAA8D;SAC/D;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAAkC;IACvE,MAAM,KAAK,GAAG,QAAQ,CAAC,qBAAqB,IAAI,SAAS,CAAC;IAC1D,MAAM,WAAW,GAAG,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC5E,OAAO,GAAG,KAAK,KAAK,WAAW,GAAG,CAAC;AACrC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=delegationRecovery.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegationRecovery.test.d.ts","sourceRoot":"","sources":["../../src/utils/delegationRecovery.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { evaluateDelegationHealth } from './delegationRecovery.js';
4
+ const baseMetadata = {
5
+ provider: 'cursor',
6
+ providerRuntime: 'cli',
7
+ providerStatus: 'running',
8
+ providerChatId: 'chat_123',
9
+ providerLaunchedAt: '2026-01-01T00:00:00.000Z',
10
+ providerLastSyncAt: '2026-01-01T00:05:00.000Z',
11
+ };
12
+ test('marks non-zero exit codes as recoverable failures', () => {
13
+ const result = evaluateDelegationHealth({
14
+ metadata: baseMetadata,
15
+ isRunning: false,
16
+ exitCode: 1,
17
+ staleAfterMs: 60_000,
18
+ });
19
+ assert.equal(result.state, 'failed');
20
+ assert.equal(result.recoverable, true);
21
+ assert.match(result.reason ?? '', /exited with code 1/);
22
+ });
23
+ test('marks missing process without exit code as stale after threshold', () => {
24
+ const result = evaluateDelegationHealth({
25
+ metadata: baseMetadata,
26
+ isRunning: false,
27
+ now: new Date('2026-01-01T00:20:00.000Z'),
28
+ staleAfterMs: 5 * 60 * 1000,
29
+ });
30
+ assert.equal(result.state, 'stale');
31
+ assert.equal(result.recoverable, true);
32
+ });
33
+ test('marks running delegations as healthy', () => {
34
+ const result = evaluateDelegationHealth({
35
+ metadata: baseMetadata,
36
+ isRunning: true,
37
+ staleAfterMs: 60_000,
38
+ });
39
+ assert.equal(result.state, 'healthy');
40
+ assert.equal(result.recoverable, false);
41
+ });
42
+ //# sourceMappingURL=delegationRecovery.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegationRecovery.test.js","sourceRoot":"","sources":["../../src/utils/delegationRecovery.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,MAAM,YAAY,GAA6B;IAC7C,QAAQ,EAAE,QAAQ;IAClB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,SAAS;IACzB,cAAc,EAAE,UAAU;IAC1B,kBAAkB,EAAE,0BAA0B;IAC9C,kBAAkB,EAAE,0BAA0B;CAC/C,CAAC;AAEF,IAAI,CAAC,mDAAmD,EAAE,GAAG,EAAE;IAC7D,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,QAAQ,EAAE,YAAY;QACtB,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,CAAC;QACX,YAAY,EAAE,MAAM;KACrB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACvC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,oBAAoB,CAAC,CAAC;AAC1D,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,kEAAkE,EAAE,GAAG,EAAE;IAC5E,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,QAAQ,EAAE,YAAY;QACtB,SAAS,EAAE,KAAK;QAChB,GAAG,EAAE,IAAI,IAAI,CAAC,0BAA0B,CAAC;QACzC,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;KAC5B,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,sCAAsC,EAAE,GAAG,EAAE;IAChD,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,QAAQ,EAAE,YAAY;QACtB,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,MAAM;KACrB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACtC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { CursorProviderMode, ProviderRuntime, TaskComplexity } from '../models.js';
2
+ export interface CursorProviderConfig {
3
+ binary: string;
4
+ runtime: ProviderRuntime;
5
+ defaultMode: Exclude<CursorProviderMode, 'cloud'>;
6
+ defaultForce: boolean;
7
+ autoApproveMcps: boolean;
8
+ trustWorkspace: boolean;
9
+ useCreateChat: boolean;
10
+ logDir: string;
11
+ defaultModel?: string;
12
+ preferWorktreeFor: TaskComplexity[];
13
+ recoveryStaleAfterMs: number;
14
+ }
15
+ export interface OrchestratorConfig {
16
+ cursor: CursorProviderConfig;
17
+ }
18
+ export declare function loadOrchestratorConfig(cwd?: string): OrchestratorConfig;
19
+ //# sourceMappingURL=orchestratorConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestratorConfig.d.ts","sourceRoot":"","sources":["../../src/utils/orchestratorConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAElB,eAAe,EACf,cAAc,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAClD,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,cAAc,EAAE,CAAC;IACpC,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,oBAAoB,CAAC;CAC9B;AAqBD,wBAAgB,sBAAsB,CAAC,GAAG,GAAE,MAAsB,GAAG,kBAAkB,CAmBtF"}
@@ -0,0 +1,38 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { DEFAULT_CURSOR_WORKTREE_COMPLEXITIES, } from '../models.js';
4
+ const DEFAULT_CONFIG = {
5
+ cursor: {
6
+ binary: process.env.CURSOR_AGENT_BINARY || 'agent',
7
+ runtime: 'cli',
8
+ defaultMode: 'agent',
9
+ defaultForce: true,
10
+ autoApproveMcps: true,
11
+ trustWorkspace: true,
12
+ useCreateChat: true,
13
+ logDir: path.join('.agent-orchestration', 'providers', 'cursor'),
14
+ preferWorktreeFor: DEFAULT_CURSOR_WORKTREE_COMPLEXITIES,
15
+ recoveryStaleAfterMs: 10 * 60 * 1000,
16
+ },
17
+ };
18
+ export function loadOrchestratorConfig(cwd = process.cwd()) {
19
+ const configPath = path.join(cwd, 'agent-orchestration.config.json');
20
+ if (!fs.existsSync(configPath)) {
21
+ return DEFAULT_CONFIG;
22
+ }
23
+ try {
24
+ const content = fs.readFileSync(configPath, 'utf-8');
25
+ const parsed = JSON.parse(content);
26
+ return {
27
+ cursor: {
28
+ ...DEFAULT_CONFIG.cursor,
29
+ ...parsed.cursor,
30
+ preferWorktreeFor: parsed.cursor?.preferWorktreeFor ?? DEFAULT_CONFIG.cursor.preferWorktreeFor,
31
+ },
32
+ };
33
+ }
34
+ catch {
35
+ return DEFAULT_CONFIG;
36
+ }
37
+ }
38
+ //# sourceMappingURL=orchestratorConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestratorConfig.js","sourceRoot":"","sources":["../../src/utils/orchestratorConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAEL,oCAAoC,GAGrC,MAAM,cAAc,CAAC;AAwBtB,MAAM,cAAc,GAAuB;IACzC,MAAM,EAAE;QACN,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO;QAClD,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,OAAO;QACpB,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,IAAI;QACrB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;QACnB,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,WAAW,EAAE,QAAQ,CAAC;QAChE,iBAAiB,EAAE,oCAAoC;QACvD,oBAAoB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;KACrC;CACF,CAAC;AAEF,MAAM,UAAU,sBAAsB,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IAChE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iCAAiC,CAAC,CAAC;IACrE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB,CAAC;QACxD,OAAO;YACL,MAAM,EAAE;gBACN,GAAG,cAAc,CAAC,MAAM;gBACxB,GAAG,MAAM,CAAC,MAAM;gBAChB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,IAAI,cAAc,CAAC,MAAM,CAAC,iBAAiB;aAC/F;SACF,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,cAAc,CAAC;IACxB,CAAC;AACH,CAAC"}
@@ -0,0 +1,27 @@
1
+ export interface CommandResult {
2
+ success: boolean;
3
+ stdout: string;
4
+ stderr: string;
5
+ exitCode: number | null;
6
+ }
7
+ export interface DetachedCommandInput {
8
+ command: string;
9
+ args: string[];
10
+ cwd: string;
11
+ logPath: string;
12
+ exitCodePath: string;
13
+ env?: NodeJS.ProcessEnv;
14
+ }
15
+ export interface DetachedCommandResult {
16
+ pid: number;
17
+ command: string;
18
+ }
19
+ export declare function runCommand(command: string, args: string[], options?: {
20
+ cwd?: string;
21
+ env?: NodeJS.ProcessEnv;
22
+ }): CommandResult;
23
+ export declare function commandExists(command: string, cwd?: string): boolean;
24
+ export declare function formatCommand(command: string, args: string[]): string;
25
+ export declare function spawnDetachedCommand(input: DetachedCommandInput): DetachedCommandResult;
26
+ export declare function isProcessRunning(pid: number | undefined): boolean;
27
+ //# sourceMappingURL=subprocess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subprocess.d.ts","sourceRoot":"","sources":["../../src/utils/subprocess.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,GAClD,aAAa,CAaf;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,OAAO,CAKnF;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAUrE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB,CA+CvF;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAWjE"}
@@ -0,0 +1,84 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { spawn, spawnSync } from 'child_process';
4
+ export function runCommand(command, args, options) {
5
+ const result = spawnSync(command, args, {
6
+ cwd: options?.cwd,
7
+ env: options?.env,
8
+ encoding: 'utf-8',
9
+ });
10
+ return {
11
+ success: result.status === 0,
12
+ stdout: result.stdout ?? '',
13
+ stderr: result.stderr ?? '',
14
+ exitCode: result.status,
15
+ };
16
+ }
17
+ export function commandExists(command, cwd = process.cwd()) {
18
+ const probe = process.platform === 'win32'
19
+ ? runCommand('where', [command], { cwd })
20
+ : runCommand('which', [command], { cwd });
21
+ return probe.success;
22
+ }
23
+ export function formatCommand(command, args) {
24
+ const shellQuote = (value) => {
25
+ if (/^[A-Za-z0-9_./:=+-]+$/.test(value)) {
26
+ return value;
27
+ }
28
+ return `'${value.replace(/'/g, `'\\''`)}'`;
29
+ };
30
+ return [command, ...args].map(shellQuote).join(' ');
31
+ }
32
+ export function spawnDetachedCommand(input) {
33
+ fs.mkdirSync(path.dirname(input.logPath), { recursive: true });
34
+ fs.mkdirSync(path.dirname(input.exitCodePath), { recursive: true });
35
+ const encodedPayload = Buffer.from(JSON.stringify({
36
+ ...input,
37
+ env: { ...process.env, ...input.env },
38
+ }), 'utf-8').toString('base64');
39
+ const wrapper = `
40
+ const fs = require('fs');
41
+ const { spawn } = require('child_process');
42
+ const payload = JSON.parse(Buffer.from(process.argv[1], 'base64').toString('utf8'));
43
+ const stream = fs.createWriteStream(payload.logPath, { flags: 'a' });
44
+ const child = spawn(payload.command, payload.args, {
45
+ cwd: payload.cwd,
46
+ env: payload.env,
47
+ stdio: ['ignore', 'pipe', 'pipe'],
48
+ });
49
+ child.stdout.on('data', (chunk) => stream.write(chunk));
50
+ child.stderr.on('data', (chunk) => stream.write(chunk));
51
+ child.on('error', (error) => {
52
+ stream.write(String(error) + '\\n');
53
+ fs.writeFileSync(payload.exitCodePath, '1', 'utf-8');
54
+ stream.end(() => process.exit(0));
55
+ });
56
+ child.on('close', (code) => {
57
+ fs.writeFileSync(payload.exitCodePath, String(code ?? 0), 'utf-8');
58
+ stream.end(() => process.exit(0));
59
+ });
60
+ `;
61
+ const child = spawn(process.execPath, ['-e', wrapper, encodedPayload], {
62
+ cwd: input.cwd,
63
+ detached: true,
64
+ stdio: 'ignore',
65
+ });
66
+ child.unref();
67
+ return {
68
+ pid: child.pid ?? -1,
69
+ command: formatCommand(input.command, input.args),
70
+ };
71
+ }
72
+ export function isProcessRunning(pid) {
73
+ if (!pid || pid <= 0) {
74
+ return false;
75
+ }
76
+ try {
77
+ process.kill(pid, 0);
78
+ return true;
79
+ }
80
+ catch {
81
+ return false;
82
+ }
83
+ }
84
+ //# sourceMappingURL=subprocess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subprocess.js","sourceRoot":"","sources":["../../src/utils/subprocess.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,18 +1,29 @@
1
1
  {
2
2
  "name": "agent-orchestration",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Agent Orchestration - MCP server for multi-agent coordination across IDEs and CLI tools",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
8
8
  "agent-orchestration": "dist/bin/cli.js"
9
9
  },
10
+ "files": [
11
+ "dist",
12
+ "templates",
13
+ ".cursor/rules",
14
+ "README.md",
15
+ "LICENSE",
16
+ "package.json"
17
+ ],
10
18
  "scripts": {
11
- "build": "tsc",
12
- "dev": "tsc --watch",
19
+ "build": "node ./node_modules/typescript/bin/tsc",
20
+ "dev": "node ./node_modules/typescript/bin/tsc --watch",
13
21
  "start": "node dist/index.js",
14
- "lint": "eslint src --ext .ts",
15
- "clean": "rm -rf dist"
22
+ "lint": "node ./node_modules/typescript/bin/tsc -p tsconfig.json --noEmit",
23
+ "test": "npm run build && node --test dist/**/*.test.js",
24
+ "clean": "rm -rf dist",
25
+ "prepack": "npm run build",
26
+ "release": "release-it"
16
27
  },
17
28
  "keywords": [
18
29
  "mcp",
@@ -46,6 +57,7 @@
46
57
  "devDependencies": {
47
58
  "@types/better-sqlite3": "^7.6.12",
48
59
  "@types/node": "^22.10.5",
60
+ "release-it": "^19.2.2",
49
61
  "typescript": "^5.7.3"
50
62
  },
51
63
  "engines": {
@@ -0,0 +1,164 @@
1
+ # AGENTS.md
2
+
3
+ This project uses **Agent Orchestration** for multi-agent coordination.
4
+
5
+ ## MCP Server Setup
6
+
7
+ Add this to your IDE's MCP configuration:
8
+
9
+ ```json
10
+ {
11
+ "mcpServers": {
12
+ "agent-orchestration": {
13
+ "command": "npx",
14
+ "args": ["-y", "agent-orchestration", "serve"],
15
+ "env": {
16
+ "MCP_ORCH_SYNC_CONTEXT": "true"
17
+ }
18
+ }
19
+ }
20
+ }
21
+ ```
22
+
23
+ **Note**: Run from your project root. The server uses the current directory.
24
+
25
+ ---
26
+
27
+ ## First Action: Bootstrap
28
+
29
+ Before doing any work, you MUST run:
30
+
31
+ ```
32
+ bootstrap
33
+ ```
34
+
35
+ **Important**: `bootstrap` is an MCP **tool invocation inside your agent/IDE**, not a terminal command.
36
+
37
+ This registers you with the orchestrator and shows:
38
+ - Current project focus
39
+ - Tasks assigned to you
40
+ - Recent decisions
41
+
42
+ ---
43
+
44
+ ## If You Have a Specific Task
45
+
46
+ If you were given a specific task to work on, run:
47
+
48
+ ```
49
+ claim_todo:
50
+ title: "<the task title>"
51
+ ```
52
+
53
+ This registers you AND claims the task in one call.
54
+
55
+ ---
56
+
57
+ ## Available Tools
58
+
59
+ ### Session Management
60
+ | Tool | Description |
61
+ |------|-------------|
62
+ | `bootstrap` | Initialize session: register, get focus, tasks, decisions |
63
+ | `claim_todo` | Register + claim a task in one call |
64
+ | `agent_whoami` | Get your current agent info |
65
+
66
+ ### Agent Coordination
67
+ | Tool | Description |
68
+ |------|-------------|
69
+ | `agent_register` | Register with the orchestration system |
70
+ | `agent_heartbeat` | Send heartbeat to indicate you're active |
71
+ | `agent_list` | List all registered agents |
72
+ | `agent_unregister` | Unregister (releases all locks) |
73
+
74
+ ### Shared Memory
75
+ | Tool | Description |
76
+ |------|-------------|
77
+ | `memory_set` | Store a value in shared memory |
78
+ | `memory_get` | Retrieve a value from shared memory |
79
+ | `memory_list` | List all keys in a namespace |
80
+ | `memory_delete` | Delete a value from shared memory |
81
+
82
+ ### Task Management
83
+ | Tool | Description |
84
+ |------|-------------|
85
+ | `task_create` | Create a new task |
86
+ | `task_claim` | Claim a task to work on |
87
+ | `task_update` | Update task status or progress |
88
+ | `task_complete` | Mark task as completed |
89
+ | `task_list` | List tasks with filters |
90
+ | `is_my_turn` | Check if work is available |
91
+
92
+ ### Resource Locking
93
+ | Tool | Description |
94
+ |------|-------------|
95
+ | `lock_acquire` | Acquire a lock on a file/resource |
96
+ | `lock_release` | Release a held lock |
97
+ | `lock_check` | Check if a resource is locked |
98
+ | `coordination_status` | Get overall system status |
99
+
100
+ ---
101
+
102
+ ## Workflow for Main Orchestrator
103
+
104
+ ```
105
+ 1. bootstrap # Start session
106
+ 2. memory_set current_focus "..." # Set project focus
107
+ 3. task_create "Feature X" # Create tasks
108
+ 4. coordination_status # Monitor progress
109
+ ```
110
+
111
+ ## Workflow for Sub-Agents
112
+
113
+ ```
114
+ 1. claim_todo "Feature X" # Register + claim
115
+ 2. lock_acquire "src/feature.ts" # Lock before editing
116
+ 3. [do the work]
117
+ 4. task_complete <task_id> "Done" # Complete the task
118
+ 5. agent_unregister # Clean up
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Memory Namespaces
124
+
125
+ Use these namespaces for organization:
126
+
127
+ | Namespace | Purpose | Example Keys |
128
+ |-----------|---------|--------------|
129
+ | `context` | Current state and focus | `current_focus`, `current_branch` |
130
+ | `decisions` | Architectural decisions | `auth_strategy`, `db_choice` |
131
+ | `findings` | Analysis results | `perf_issues`, `security_audit` |
132
+ | `blockers` | Issues blocking progress | `api_down`, `missing_deps` |
133
+
134
+ ---
135
+
136
+ ## Coordination Patterns
137
+
138
+ ### Before Editing Files
139
+ ```
140
+ lock_check: { resource: "src/file.ts" }
141
+ lock_acquire: { resource: "src/file.ts", reason: "Implementing feature" }
142
+ ```
143
+
144
+ ### After Editing Files
145
+ ```
146
+ lock_release: { resource: "src/file.ts" }
147
+ ```
148
+
149
+ ### Check Before Major Work
150
+ ```
151
+ is_my_turn
152
+ ```
153
+
154
+ ### When Done
155
+ ```
156
+ task_complete: { task_id: "<id>", output: "Summary of changes" }
157
+ agent_unregister
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Reference activeContext.md
163
+
164
+ Check `activeContext.md` for current project state - it's auto-updated.
package/activeContext.md DELETED
@@ -1,37 +0,0 @@
1
- # Active Context
2
-
3
- _Last updated: Renamed to Agent Orchestration_
4
-
5
- ## Current Focus
6
-
7
- Agent Orchestration - MCP server for multi-agent coordination across IDEs and CLI tools.
8
-
9
- ## Active Agents
10
-
11
- _No active agents. Start the MCP server and register agents to see them here._
12
-
13
- ## In Progress
14
-
15
- _No tasks in progress._
16
-
17
- ## Pending Tasks
18
-
19
- _No pending tasks. Create tasks using the `task_create` tool._
20
-
21
- ## Recent Decisions
22
-
23
- - **name**: Renamed from mcp-orchestrator to agent-orchestration
24
- - **compatibility**: Added AGENTS.md support for cross-IDE compatibility
25
- - **runtime**: TypeScript/Node.js for easier installation
26
- - **database**: better-sqlite3 for synchronous, high-performance SQLite
27
-
28
- ## Context Notes
29
-
30
- - **turn_based_execution**: Agents check `is_my_turn` before starting work
31
- - **sub_agent_workflow**: Sub-agents use `claim_todo` to register + claim in one call
32
- - **shared_memory_namespaces**: context, decisions, findings, blockers
33
-
34
- ---
35
-
36
- _This file is auto-generated by the Agent Orchestration server._
37
- _Edit shared memory to update this context._