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.
- package/.cursor/rules/orchestrator-auto.mdc +107 -0
- package/.cursor/rules/orchestrator-main.mdc +86 -0
- package/.cursor/rules/orchestrator-sub.mdc +114 -0
- package/LICENSE +21 -0
- package/README.md +329 -0
- package/activeContext.md +37 -0
- package/dist/bin/cli.d.ts +11 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +410 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/database.d.ts +91 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +522 -0
- package/dist/database.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +132 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +124 -0
- package/dist/models.js.map +1 -0
- package/dist/tools/agent.d.ts +10 -0
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +185 -0
- package/dist/tools/agent.js.map +1 -0
- package/dist/tools/coordination.d.ts +6 -0
- package/dist/tools/coordination.d.ts.map +1 -0
- package/dist/tools/coordination.js +114 -0
- package/dist/tools/coordination.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/memory.d.ts +6 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +108 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/task.d.ts +6 -0
- package/dist/tools/task.d.ts.map +1 -0
- package/dist/tools/task.js +267 -0
- package/dist/tools/task.js.map +1 -0
- package/dist/tools/utility.d.ts +6 -0
- package/dist/tools/utility.d.ts.map +1 -0
- package/dist/tools/utility.js +162 -0
- package/dist/tools/utility.js.map +1 -0
- package/dist/utils/contextSync.d.ts +12 -0
- package/dist/utils/contextSync.d.ts.map +1 -0
- package/dist/utils/contextSync.js +124 -0
- package/dist/utils/contextSync.js.map +1 -0
- package/package.json +54 -0
- package/src/bin/cli.ts +430 -0
- package/src/database.ts +764 -0
- package/src/index.ts +71 -0
- package/src/models.ts +226 -0
- package/src/tools/agent.ts +241 -0
- package/src/tools/coordination.ts +152 -0
- package/src/tools/index.ts +9 -0
- package/src/tools/memory.ts +150 -0
- package/src/tools/task.ts +334 -0
- package/src/tools/utility.ts +202 -0
- package/src/utils/contextSync.ts +144 -0
- package/tsconfig.json +20 -0
package/dist/bin/cli.js
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI for Agent Orchestration
|
|
4
|
+
*
|
|
5
|
+
* Commands:
|
|
6
|
+
* init - Creates AGENTS.md for cross-IDE/CLI compatibility
|
|
7
|
+
* init-cursor - Copies .cursor/rules/ for Cursor IDE
|
|
8
|
+
* serve - Run the MCP server (used by IDEs via npx)
|
|
9
|
+
*/
|
|
10
|
+
import * as fs from 'fs';
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = path.dirname(__filename);
|
|
15
|
+
// Path to the package root (dist/bin/cli.js -> ../../)
|
|
16
|
+
const packageRoot = path.resolve(__dirname, '..', '..');
|
|
17
|
+
function printUsage() {
|
|
18
|
+
console.log(`
|
|
19
|
+
Agent Orchestration CLI
|
|
20
|
+
|
|
21
|
+
Usage:
|
|
22
|
+
npx agent-orchestration init Create AGENTS.md (works with any AI agent)
|
|
23
|
+
npx agent-orchestration init-cursor Setup for Cursor IDE (.cursor/rules/)
|
|
24
|
+
npx agent-orchestration serve Run the MCP server
|
|
25
|
+
npx agent-orchestration help Show this help message
|
|
26
|
+
|
|
27
|
+
Commands:
|
|
28
|
+
init Creates AGENTS.md with full orchestration instructions.
|
|
29
|
+
Compatible with: OpenAI Codex, Google Jules, Cursor, Aider,
|
|
30
|
+
Windsurf, VS Code Copilot, and many more.
|
|
31
|
+
|
|
32
|
+
init-cursor Sets up Cursor-specific rules in .cursor/rules/.
|
|
33
|
+
Also creates activeContext.md and updates .gitignore.
|
|
34
|
+
|
|
35
|
+
serve Runs the MCP server. IDEs call this via their MCP config.
|
|
36
|
+
The server uses the current working directory as the project root.
|
|
37
|
+
|
|
38
|
+
Example:
|
|
39
|
+
cd /path/to/my-project
|
|
40
|
+
npx agent-orchestration init
|
|
41
|
+
`);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Generate the AGENTS.md content with full orchestration instructions
|
|
45
|
+
*/
|
|
46
|
+
function generateAgentsMd() {
|
|
47
|
+
return `# AGENTS.md
|
|
48
|
+
|
|
49
|
+
This project uses **Agent Orchestration** for multi-agent coordination.
|
|
50
|
+
|
|
51
|
+
## MCP Server Setup
|
|
52
|
+
|
|
53
|
+
Add this to your IDE's MCP configuration:
|
|
54
|
+
|
|
55
|
+
\`\`\`json
|
|
56
|
+
{
|
|
57
|
+
"mcpServers": {
|
|
58
|
+
"agent-orchestration": {
|
|
59
|
+
"command": "npx",
|
|
60
|
+
"args": ["-y", "agent-orchestration", "serve"],
|
|
61
|
+
"env": {
|
|
62
|
+
"MCP_ORCH_SYNC_CONTEXT": "true"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
\`\`\`
|
|
68
|
+
|
|
69
|
+
**Note**: Run from your project root. The server uses the current directory.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## First Action: Bootstrap
|
|
74
|
+
|
|
75
|
+
Before doing any work, you MUST run:
|
|
76
|
+
|
|
77
|
+
\`\`\`
|
|
78
|
+
bootstrap
|
|
79
|
+
\`\`\`
|
|
80
|
+
|
|
81
|
+
This registers you with the orchestrator and shows:
|
|
82
|
+
- Current project focus
|
|
83
|
+
- Tasks assigned to you
|
|
84
|
+
- Recent decisions
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## If You Have a Specific Task
|
|
89
|
+
|
|
90
|
+
If you were given a specific task to work on, run:
|
|
91
|
+
|
|
92
|
+
\`\`\`
|
|
93
|
+
claim_todo:
|
|
94
|
+
title: "<the task title>"
|
|
95
|
+
\`\`\`
|
|
96
|
+
|
|
97
|
+
This registers you AND claims the task in one call.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Available Tools
|
|
102
|
+
|
|
103
|
+
### Session Management
|
|
104
|
+
| Tool | Description |
|
|
105
|
+
|------|-------------|
|
|
106
|
+
| \`bootstrap\` | Initialize session: register, get focus, tasks, decisions |
|
|
107
|
+
| \`claim_todo\` | Register + claim a task in one call |
|
|
108
|
+
| \`agent_whoami\` | Get your current agent info |
|
|
109
|
+
|
|
110
|
+
### Agent Coordination
|
|
111
|
+
| Tool | Description |
|
|
112
|
+
|------|-------------|
|
|
113
|
+
| \`agent_register\` | Register with the orchestration system |
|
|
114
|
+
| \`agent_heartbeat\` | Send heartbeat to indicate you're active |
|
|
115
|
+
| \`agent_list\` | List all registered agents |
|
|
116
|
+
| \`agent_unregister\` | Unregister (releases all locks) |
|
|
117
|
+
|
|
118
|
+
### Shared Memory
|
|
119
|
+
| Tool | Description |
|
|
120
|
+
|------|-------------|
|
|
121
|
+
| \`memory_set\` | Store a value in shared memory |
|
|
122
|
+
| \`memory_get\` | Retrieve a value from shared memory |
|
|
123
|
+
| \`memory_list\` | List all keys in a namespace |
|
|
124
|
+
| \`memory_delete\` | Delete a value from shared memory |
|
|
125
|
+
|
|
126
|
+
### Task Management
|
|
127
|
+
| Tool | Description |
|
|
128
|
+
|------|-------------|
|
|
129
|
+
| \`task_create\` | Create a new task |
|
|
130
|
+
| \`task_claim\` | Claim a task to work on |
|
|
131
|
+
| \`task_update\` | Update task status or progress |
|
|
132
|
+
| \`task_complete\` | Mark task as completed |
|
|
133
|
+
| \`task_list\` | List tasks with filters |
|
|
134
|
+
| \`is_my_turn\` | Check if work is available |
|
|
135
|
+
|
|
136
|
+
### Resource Locking
|
|
137
|
+
| Tool | Description |
|
|
138
|
+
|------|-------------|
|
|
139
|
+
| \`lock_acquire\` | Acquire a lock on a file/resource |
|
|
140
|
+
| \`lock_release\` | Release a held lock |
|
|
141
|
+
| \`lock_check\` | Check if a resource is locked |
|
|
142
|
+
| \`coordination_status\` | Get overall system status |
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Workflow for Main Orchestrator
|
|
147
|
+
|
|
148
|
+
\`\`\`
|
|
149
|
+
1. bootstrap # Start session
|
|
150
|
+
2. memory_set current_focus "..." # Set project focus
|
|
151
|
+
3. task_create "Feature X" # Create tasks
|
|
152
|
+
4. coordination_status # Monitor progress
|
|
153
|
+
\`\`\`
|
|
154
|
+
|
|
155
|
+
## Workflow for Sub-Agents
|
|
156
|
+
|
|
157
|
+
\`\`\`
|
|
158
|
+
1. claim_todo "Feature X" # Register + claim
|
|
159
|
+
2. lock_acquire "src/feature.ts" # Lock before editing
|
|
160
|
+
3. [do the work]
|
|
161
|
+
4. task_complete <task_id> "Done" # Complete the task
|
|
162
|
+
5. agent_unregister # Clean up
|
|
163
|
+
\`\`\`
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Memory Namespaces
|
|
168
|
+
|
|
169
|
+
Use these namespaces for organization:
|
|
170
|
+
|
|
171
|
+
| Namespace | Purpose | Example Keys |
|
|
172
|
+
|-----------|---------|--------------|
|
|
173
|
+
| \`context\` | Current state and focus | \`current_focus\`, \`current_branch\` |
|
|
174
|
+
| \`decisions\` | Architectural decisions | \`auth_strategy\`, \`db_choice\` |
|
|
175
|
+
| \`findings\` | Analysis results | \`perf_issues\`, \`security_audit\` |
|
|
176
|
+
| \`blockers\` | Issues blocking progress | \`api_down\`, \`missing_deps\` |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Coordination Patterns
|
|
181
|
+
|
|
182
|
+
### Before Editing Files
|
|
183
|
+
\`\`\`
|
|
184
|
+
lock_check: { resource: "src/file.ts" }
|
|
185
|
+
lock_acquire: { resource: "src/file.ts", reason: "Implementing feature" }
|
|
186
|
+
\`\`\`
|
|
187
|
+
|
|
188
|
+
### After Editing Files
|
|
189
|
+
\`\`\`
|
|
190
|
+
lock_release: { resource: "src/file.ts" }
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
### Check Before Major Work
|
|
194
|
+
\`\`\`
|
|
195
|
+
is_my_turn
|
|
196
|
+
\`\`\`
|
|
197
|
+
|
|
198
|
+
### When Done
|
|
199
|
+
\`\`\`
|
|
200
|
+
task_complete: { task_id: "<id>", output: "Summary of changes" }
|
|
201
|
+
agent_unregister
|
|
202
|
+
\`\`\`
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Reference activeContext.md
|
|
207
|
+
|
|
208
|
+
Check \`activeContext.md\` for current project state - it's auto-updated.
|
|
209
|
+
`;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Run the MCP server
|
|
213
|
+
*/
|
|
214
|
+
async function runServer() {
|
|
215
|
+
// Import and start the server
|
|
216
|
+
const { startServer } = await import('../index.js');
|
|
217
|
+
await startServer();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Initialize with AGENTS.md (cross-IDE compatible)
|
|
221
|
+
*/
|
|
222
|
+
function initAgentsMd() {
|
|
223
|
+
const cwd = process.cwd();
|
|
224
|
+
console.log(`\nInitializing Agent Orchestration (AGENTS.md) in: ${cwd}\n`);
|
|
225
|
+
// 1. Create AGENTS.md
|
|
226
|
+
const agentsMdPath = path.join(cwd, 'AGENTS.md');
|
|
227
|
+
if (!fs.existsSync(agentsMdPath)) {
|
|
228
|
+
fs.writeFileSync(agentsMdPath, generateAgentsMd());
|
|
229
|
+
console.log('✓ Created AGENTS.md');
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
console.log('✓ AGENTS.md already exists (not overwritten)');
|
|
233
|
+
}
|
|
234
|
+
// 2. Update .gitignore
|
|
235
|
+
updateGitignore(cwd);
|
|
236
|
+
// 3. Create activeContext.md
|
|
237
|
+
createActiveContext(cwd);
|
|
238
|
+
// 4. Print success message
|
|
239
|
+
console.log(`
|
|
240
|
+
✓ Setup complete!
|
|
241
|
+
|
|
242
|
+
AGENTS.md is now ready. This works with:
|
|
243
|
+
- OpenAI Codex
|
|
244
|
+
- Google Jules
|
|
245
|
+
- Cursor
|
|
246
|
+
- Aider
|
|
247
|
+
- Windsurf
|
|
248
|
+
- VS Code Copilot
|
|
249
|
+
- And many more!
|
|
250
|
+
|
|
251
|
+
MCP Server Config (add to your IDE):
|
|
252
|
+
|
|
253
|
+
{
|
|
254
|
+
"mcpServers": {
|
|
255
|
+
"agent-orchestration": {
|
|
256
|
+
"command": "npx",
|
|
257
|
+
"args": ["-y", "agent-orchestration", "serve"],
|
|
258
|
+
"env": {
|
|
259
|
+
"MCP_ORCH_SYNC_CONTEXT": "true"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
Then restart your IDE to activate the MCP server.
|
|
266
|
+
`);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Initialize for Cursor IDE (copies .cursor/rules/)
|
|
270
|
+
*/
|
|
271
|
+
function initCursor() {
|
|
272
|
+
const cwd = process.cwd();
|
|
273
|
+
console.log(`\nInitializing Agent Orchestration for Cursor in: ${cwd}\n`);
|
|
274
|
+
// 1. Copy Cursor rules
|
|
275
|
+
const rulesSourceDir = path.join(packageRoot, '.cursor', 'rules');
|
|
276
|
+
const rulesTargetDir = path.join(cwd, '.cursor', 'rules');
|
|
277
|
+
if (fs.existsSync(rulesSourceDir)) {
|
|
278
|
+
fs.mkdirSync(rulesTargetDir, { recursive: true });
|
|
279
|
+
const ruleFiles = fs.readdirSync(rulesSourceDir);
|
|
280
|
+
for (const file of ruleFiles) {
|
|
281
|
+
if (file.endsWith('.mdc')) {
|
|
282
|
+
const source = path.join(rulesSourceDir, file);
|
|
283
|
+
const target = path.join(rulesTargetDir, file);
|
|
284
|
+
fs.copyFileSync(source, target);
|
|
285
|
+
console.log(`✓ Copied rule: .cursor/rules/${file}`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
console.log('⚠ Cursor rules not found in package. Skipping rule copy.');
|
|
291
|
+
}
|
|
292
|
+
// 2. Update .gitignore
|
|
293
|
+
updateGitignore(cwd);
|
|
294
|
+
// 3. Create activeContext.md
|
|
295
|
+
createActiveContext(cwd);
|
|
296
|
+
// 4. Print MCP config
|
|
297
|
+
console.log(`
|
|
298
|
+
✓ Cursor setup complete!
|
|
299
|
+
|
|
300
|
+
Add this to your ~/.cursor/mcp.json:
|
|
301
|
+
|
|
302
|
+
{
|
|
303
|
+
"mcpServers": {
|
|
304
|
+
"agent-orchestration": {
|
|
305
|
+
"command": "npx",
|
|
306
|
+
"args": ["-y", "agent-orchestration", "serve"],
|
|
307
|
+
"env": {
|
|
308
|
+
"MCP_ORCH_SYNC_CONTEXT": "true"
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
Then restart Cursor to activate the MCP server.
|
|
315
|
+
`);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Update .gitignore with orchestration entries
|
|
319
|
+
*/
|
|
320
|
+
function updateGitignore(cwd) {
|
|
321
|
+
const gitignorePath = path.join(cwd, '.gitignore');
|
|
322
|
+
const ignoreEntry = '.agent-orchestration/';
|
|
323
|
+
let gitignoreContent = '';
|
|
324
|
+
if (fs.existsSync(gitignorePath)) {
|
|
325
|
+
gitignoreContent = fs.readFileSync(gitignorePath, 'utf-8');
|
|
326
|
+
}
|
|
327
|
+
if (!gitignoreContent.includes(ignoreEntry)) {
|
|
328
|
+
const newContent = gitignoreContent.trim() + '\n\n# Agent Orchestration\n' + ignoreEntry + '\n';
|
|
329
|
+
fs.writeFileSync(gitignorePath, newContent);
|
|
330
|
+
console.log('✓ Added .agent-orchestration/ to .gitignore');
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
console.log('✓ .gitignore already contains .agent-orchestration/');
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Create activeContext.md template
|
|
338
|
+
*/
|
|
339
|
+
function createActiveContext(cwd) {
|
|
340
|
+
const activeContextPath = path.join(cwd, 'activeContext.md');
|
|
341
|
+
if (!fs.existsSync(activeContextPath)) {
|
|
342
|
+
const template = `# Active Context
|
|
343
|
+
|
|
344
|
+
_Last updated: Initial setup_
|
|
345
|
+
|
|
346
|
+
## Current Focus
|
|
347
|
+
|
|
348
|
+
_Not set. Use \`memory_set\` with key "current_focus" in namespace "context"._
|
|
349
|
+
|
|
350
|
+
## Active Agents
|
|
351
|
+
|
|
352
|
+
_No active agents. Start the MCP server and register agents to see them here._
|
|
353
|
+
|
|
354
|
+
## In Progress
|
|
355
|
+
|
|
356
|
+
_No tasks in progress._
|
|
357
|
+
|
|
358
|
+
## Pending Tasks
|
|
359
|
+
|
|
360
|
+
_No pending tasks. Create tasks using the \`task_create\` tool._
|
|
361
|
+
|
|
362
|
+
## Recent Decisions
|
|
363
|
+
|
|
364
|
+
_No decisions recorded. Use \`memory_set\` in namespace "decisions" to record decisions._
|
|
365
|
+
|
|
366
|
+
## Context Notes
|
|
367
|
+
|
|
368
|
+
_No additional context._
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
_This file is auto-generated by the Agent Orchestration server._
|
|
373
|
+
_Edit shared memory to update this context._
|
|
374
|
+
`;
|
|
375
|
+
fs.writeFileSync(activeContextPath, template);
|
|
376
|
+
console.log('✓ Created activeContext.md');
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
console.log('✓ activeContext.md already exists');
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
// Main
|
|
383
|
+
const args = process.argv.slice(2);
|
|
384
|
+
const command = args[0];
|
|
385
|
+
switch (command) {
|
|
386
|
+
case 'init':
|
|
387
|
+
initAgentsMd();
|
|
388
|
+
break;
|
|
389
|
+
case 'init-cursor':
|
|
390
|
+
initCursor();
|
|
391
|
+
break;
|
|
392
|
+
case 'serve':
|
|
393
|
+
runServer().catch((err) => {
|
|
394
|
+
console.error('Server error:', err);
|
|
395
|
+
process.exit(1);
|
|
396
|
+
});
|
|
397
|
+
break;
|
|
398
|
+
case 'help':
|
|
399
|
+
case '--help':
|
|
400
|
+
case '-h':
|
|
401
|
+
printUsage();
|
|
402
|
+
break;
|
|
403
|
+
default:
|
|
404
|
+
if (command) {
|
|
405
|
+
console.error(`Unknown command: ${command}`);
|
|
406
|
+
}
|
|
407
|
+
printUsage();
|
|
408
|
+
process.exit(command ? 1 : 0);
|
|
409
|
+
}
|
|
410
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/bin/cli.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,uDAAuD;AACvD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAExD,SAAS,UAAU;IACjB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;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G,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAExB,QAAQ,OAAO,EAAE,CAAC;IAChB,KAAK,MAAM;QACT,YAAY,EAAE,CAAC;QACf,MAAM;IACR,KAAK,aAAa;QAChB,UAAU,EAAE,CAAC;QACb,MAAM;IACR,KAAK,OAAO;QACV,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACxB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QACH,MAAM;IACR,KAAK,MAAM,CAAC;IACZ,KAAK,QAAQ,CAAC;IACd,KAAK,IAAI;QACP,UAAU,EAAE,CAAC;QACb,MAAM;IACR;QACE,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;QAC/C,CAAC;QACD,UAAU,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite database operations for MCP Orchestrator
|
|
3
|
+
* Uses better-sqlite3 for synchronous, high-performance SQLite access
|
|
4
|
+
*/
|
|
5
|
+
import { Agent, AgentRole, AgentStatus, Event, EventType, Lock, MemoryEntry, Task, TaskPriority, TaskStatus } from './models.js';
|
|
6
|
+
export declare class OrchestratorDatabase {
|
|
7
|
+
private db;
|
|
8
|
+
readonly dbPath: string;
|
|
9
|
+
constructor(dbPath?: string);
|
|
10
|
+
close(): void;
|
|
11
|
+
createAgent(params: {
|
|
12
|
+
name: string;
|
|
13
|
+
role?: AgentRole;
|
|
14
|
+
capabilities?: string[];
|
|
15
|
+
status?: AgentStatus;
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
}): Agent;
|
|
18
|
+
getAgent(agentId: string): Agent | null;
|
|
19
|
+
getAgentByName(name: string): Agent | null;
|
|
20
|
+
listAgents(filters?: {
|
|
21
|
+
status?: AgentStatus;
|
|
22
|
+
role?: AgentRole;
|
|
23
|
+
}): Agent[];
|
|
24
|
+
updateAgentHeartbeat(agentId: string, status?: AgentStatus): boolean;
|
|
25
|
+
deleteAgent(agentId: string): boolean;
|
|
26
|
+
private rowToAgent;
|
|
27
|
+
cleanupStaleAgents(ttlSeconds?: number): number;
|
|
28
|
+
createTask(params: {
|
|
29
|
+
title: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
priority?: TaskPriority;
|
|
32
|
+
createdBy?: string | null;
|
|
33
|
+
assignedTo?: string | null;
|
|
34
|
+
dependencies?: string[];
|
|
35
|
+
metadata?: Record<string, unknown>;
|
|
36
|
+
status?: TaskStatus;
|
|
37
|
+
startedAt?: Date | null;
|
|
38
|
+
}): Task;
|
|
39
|
+
getTask(taskId: string): Task | null;
|
|
40
|
+
listTasks(filters?: {
|
|
41
|
+
status?: TaskStatus;
|
|
42
|
+
assignedTo?: string;
|
|
43
|
+
createdBy?: string;
|
|
44
|
+
}): Task[];
|
|
45
|
+
updateTask(taskId: string, updates: {
|
|
46
|
+
status?: TaskStatus;
|
|
47
|
+
assignedTo?: string | null;
|
|
48
|
+
output?: string;
|
|
49
|
+
metadata?: Record<string, unknown>;
|
|
50
|
+
}): Task | null;
|
|
51
|
+
checkDependenciesMet(taskId: string): boolean;
|
|
52
|
+
getNextAvailableTask(agentId: string): Task | null;
|
|
53
|
+
private rowToTask;
|
|
54
|
+
setMemory(params: {
|
|
55
|
+
key: string;
|
|
56
|
+
value: unknown;
|
|
57
|
+
namespace?: string;
|
|
58
|
+
createdBy?: string | null;
|
|
59
|
+
ttlSeconds?: number | null;
|
|
60
|
+
}): MemoryEntry;
|
|
61
|
+
getMemory(key: string, namespace?: string): MemoryEntry | null;
|
|
62
|
+
listMemory(namespace?: string): MemoryEntry[];
|
|
63
|
+
deleteMemory(key: string, namespace?: string): boolean;
|
|
64
|
+
private cleanupExpiredMemory;
|
|
65
|
+
private rowToMemory;
|
|
66
|
+
acquireLock(params: {
|
|
67
|
+
resource: string;
|
|
68
|
+
heldBy: string;
|
|
69
|
+
timeoutSeconds?: number;
|
|
70
|
+
metadata?: Record<string, unknown>;
|
|
71
|
+
}): Lock | null;
|
|
72
|
+
releaseLock(resource: string, agentId: string): boolean;
|
|
73
|
+
releaseAgentLocks(agentId: string): number;
|
|
74
|
+
checkLock(resource: string): Lock | null;
|
|
75
|
+
private cleanupExpiredLocks;
|
|
76
|
+
private logEvent;
|
|
77
|
+
listEvents(filters?: {
|
|
78
|
+
agentId?: string;
|
|
79
|
+
eventType?: EventType;
|
|
80
|
+
limit?: number;
|
|
81
|
+
}): Event[];
|
|
82
|
+
getStats(): {
|
|
83
|
+
agents: number;
|
|
84
|
+
tasks: number;
|
|
85
|
+
locks: number;
|
|
86
|
+
memory: number;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export declare function getDatabase(): OrchestratorDatabase;
|
|
90
|
+
export declare function closeDatabase(): void;
|
|
91
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACL,KAAK,EACL,SAAS,EACT,WAAW,EAMX,KAAK,EACL,SAAS,EACT,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,UAAU,EACX,MAAM,aAAa,CAAC;AA0GrB,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,EAAE,CAAoB;IAC9B,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,MAAM,CAAC,EAAE,MAAM;IAuB3B,KAAK,IAAI,IAAI;IAM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