agent-orchestration 0.5.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 (63) hide show
  1. package/.cursor/rules/orchestrator-auto.mdc +107 -0
  2. package/.cursor/rules/orchestrator-main.mdc +86 -0
  3. package/.cursor/rules/orchestrator-sub.mdc +114 -0
  4. package/LICENSE +21 -0
  5. package/README.md +329 -0
  6. package/activeContext.md +37 -0
  7. package/dist/bin/cli.d.ts +11 -0
  8. package/dist/bin/cli.d.ts.map +1 -0
  9. package/dist/bin/cli.js +410 -0
  10. package/dist/bin/cli.js.map +1 -0
  11. package/dist/database.d.ts +91 -0
  12. package/dist/database.d.ts.map +1 -0
  13. package/dist/database.js +522 -0
  14. package/dist/database.js.map +1 -0
  15. package/dist/index.d.ts +12 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +56 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/models.d.ts +132 -0
  20. package/dist/models.d.ts.map +1 -0
  21. package/dist/models.js +124 -0
  22. package/dist/models.js.map +1 -0
  23. package/dist/tools/agent.d.ts +10 -0
  24. package/dist/tools/agent.d.ts.map +1 -0
  25. package/dist/tools/agent.js +185 -0
  26. package/dist/tools/agent.js.map +1 -0
  27. package/dist/tools/coordination.d.ts +6 -0
  28. package/dist/tools/coordination.d.ts.map +1 -0
  29. package/dist/tools/coordination.js +114 -0
  30. package/dist/tools/coordination.js.map +1 -0
  31. package/dist/tools/index.d.ts +9 -0
  32. package/dist/tools/index.d.ts.map +1 -0
  33. package/dist/tools/index.js +9 -0
  34. package/dist/tools/index.js.map +1 -0
  35. package/dist/tools/memory.d.ts +6 -0
  36. package/dist/tools/memory.d.ts.map +1 -0
  37. package/dist/tools/memory.js +108 -0
  38. package/dist/tools/memory.js.map +1 -0
  39. package/dist/tools/task.d.ts +6 -0
  40. package/dist/tools/task.d.ts.map +1 -0
  41. package/dist/tools/task.js +267 -0
  42. package/dist/tools/task.js.map +1 -0
  43. package/dist/tools/utility.d.ts +6 -0
  44. package/dist/tools/utility.d.ts.map +1 -0
  45. package/dist/tools/utility.js +162 -0
  46. package/dist/tools/utility.js.map +1 -0
  47. package/dist/utils/contextSync.d.ts +12 -0
  48. package/dist/utils/contextSync.d.ts.map +1 -0
  49. package/dist/utils/contextSync.js +124 -0
  50. package/dist/utils/contextSync.js.map +1 -0
  51. package/package.json +54 -0
  52. package/src/bin/cli.ts +430 -0
  53. package/src/database.ts +764 -0
  54. package/src/index.ts +71 -0
  55. package/src/models.ts +226 -0
  56. package/src/tools/agent.ts +241 -0
  57. package/src/tools/coordination.ts +152 -0
  58. package/src/tools/index.ts +9 -0
  59. package/src/tools/memory.ts +150 -0
  60. package/src/tools/task.ts +334 -0
  61. package/src/tools/utility.ts +202 -0
  62. package/src/utils/contextSync.ts +144 -0
  63. package/tsconfig.json +20 -0
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Utility to sync orchestration state to activeContext.md
3
+ */
4
+
5
+ import * as fs from 'fs';
6
+ import * as path from 'path';
7
+ import { getDatabase } from '../database.js';
8
+ import { TaskStatus } from '../models.js';
9
+
10
+ /**
11
+ * Check if context sync is enabled via environment variable
12
+ */
13
+ export function isContextSyncEnabled(): boolean {
14
+ const envVar = process.env.MCP_ORCH_SYNC_CONTEXT;
15
+ return envVar === 'true' || envVar === '1';
16
+ }
17
+
18
+ /**
19
+ * Get the path to activeContext.md
20
+ */
21
+ function getContextPath(): string {
22
+ return path.join(process.cwd(), 'activeContext.md');
23
+ }
24
+
25
+ /**
26
+ * Sync the current orchestration state to activeContext.md
27
+ */
28
+ export function syncToActiveContext(): void {
29
+ if (!isContextSyncEnabled()) {
30
+ return;
31
+ }
32
+
33
+ try {
34
+ const db = getDatabase();
35
+
36
+ // Get current state
37
+ const agents = db.listAgents();
38
+ const activeAgents = agents.filter((a) => ['active', 'busy'].includes(a.status));
39
+ const inProgressTasks = db.listTasks({ status: TaskStatus.IN_PROGRESS });
40
+ const pendingTasks = db.listTasks({ status: TaskStatus.PENDING });
41
+ const decisions = db.listMemory('decisions');
42
+ const context = db.listMemory('context');
43
+
44
+ // Get current focus
45
+ const focusEntry = db.getMemory('current_focus', 'context');
46
+ const currentFocus = focusEntry
47
+ ? String(focusEntry.value)
48
+ : '_Not set. Use `memory_set` with key "current_focus" in namespace "context"._';
49
+
50
+ // Build markdown content
51
+ const lines: string[] = [
52
+ '# Active Context',
53
+ '',
54
+ `_Last updated: ${new Date().toISOString()}_`,
55
+ '',
56
+ '## Current Focus',
57
+ '',
58
+ currentFocus,
59
+ '',
60
+ '## Active Agents',
61
+ '',
62
+ ];
63
+
64
+ if (activeAgents.length === 0) {
65
+ lines.push('_No active agents._');
66
+ } else {
67
+ for (const agent of activeAgents) {
68
+ const statusEmoji = agent.status === 'busy' ? '🔵' : '🟢';
69
+ lines.push(`- ${statusEmoji} **${agent.name}** (${agent.role})`);
70
+ }
71
+ }
72
+
73
+ lines.push('', '## In Progress', '');
74
+
75
+ if (inProgressTasks.length === 0) {
76
+ lines.push('_No tasks in progress._');
77
+ } else {
78
+ for (const task of inProgressTasks) {
79
+ const progress = (task.metadata.progress as number) ?? 0;
80
+ const assignee = task.assignedTo
81
+ ? agents.find((a) => a.id === task.assignedTo)?.name ?? task.assignedTo.slice(0, 8)
82
+ : 'unassigned';
83
+ lines.push(`- 🔄 **${task.title}** - ${assignee} (${progress}%)`);
84
+ }
85
+ }
86
+
87
+ lines.push('', '## Pending Tasks', '');
88
+
89
+ if (pendingTasks.length === 0) {
90
+ lines.push('_No pending tasks._');
91
+ } else {
92
+ for (const task of pendingTasks.slice(0, 10)) {
93
+ const priority = task.priority !== 'normal' ? ` [${task.priority}]` : '';
94
+ lines.push(`- ⏳ ${task.title}${priority}`);
95
+ }
96
+ if (pendingTasks.length > 10) {
97
+ lines.push(`- _...and ${pendingTasks.length - 10} more_`);
98
+ }
99
+ }
100
+
101
+ lines.push('', '## Recent Decisions', '');
102
+
103
+ if (decisions.length === 0) {
104
+ lines.push('_No decisions recorded._');
105
+ } else {
106
+ for (const decision of decisions.slice(0, 10)) {
107
+ const value =
108
+ typeof decision.value === 'string'
109
+ ? decision.value.slice(0, 100)
110
+ : JSON.stringify(decision.value).slice(0, 100);
111
+ lines.push(`- **${decision.key}**: ${value}`);
112
+ }
113
+ }
114
+
115
+ lines.push('', '## Context Notes', '');
116
+
117
+ const otherContext = context.filter((c) => c.key !== 'current_focus');
118
+ if (otherContext.length === 0) {
119
+ lines.push('_No additional context._');
120
+ } else {
121
+ for (const entry of otherContext.slice(0, 10)) {
122
+ const value =
123
+ typeof entry.value === 'string'
124
+ ? entry.value.slice(0, 80)
125
+ : JSON.stringify(entry.value).slice(0, 80);
126
+ lines.push(`- **${entry.key}**: ${value}`);
127
+ }
128
+ }
129
+
130
+ lines.push(
131
+ '',
132
+ '---',
133
+ '',
134
+ '_This file is auto-generated by the Agent Orchestration server._',
135
+ '_Edit shared memory to update this context._'
136
+ );
137
+
138
+ // Write to file
139
+ fs.writeFileSync(getContextPath(), lines.join('\n'), 'utf-8');
140
+ } catch (error) {
141
+ // Silently fail - this is a nice-to-have feature
142
+ console.error('Failed to sync activeContext.md:', error);
143
+ }
144
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "sourceMap": true
17
+ },
18
+ "include": ["src/**/*"],
19
+ "exclude": ["node_modules", "dist"]
20
+ }