@desplega.ai/agent-swarm 1.0.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.
- package/.claude/settings.local.json +80 -0
- package/.editorconfig +15 -0
- package/.env.example +9 -0
- package/CLAUDE.md +111 -0
- package/README.md +141 -0
- package/biome.json +36 -0
- package/example-req-meta.json +24 -0
- package/package.json +46 -0
- package/src/be/db.ts +313 -0
- package/src/claude.ts +80 -0
- package/src/cli.tsx +357 -0
- package/src/commands/hook.ts +6 -0
- package/src/commands/setup.tsx +577 -0
- package/src/hooks/hook.ts +198 -0
- package/src/http.ts +262 -0
- package/src/server.ts +41 -0
- package/src/stdio.ts +21 -0
- package/src/tools/get-swarm.ts +37 -0
- package/src/tools/get-task-details.ts +48 -0
- package/src/tools/get-tasks.ts +78 -0
- package/src/tools/join-swarm.ts +102 -0
- package/src/tools/my-agent-info.ts +61 -0
- package/src/tools/poll-task.ts +109 -0
- package/src/tools/send-task.ts +62 -0
- package/src/tools/store-progress.ts +94 -0
- package/src/tools/utils.ts +115 -0
- package/src/types.ts +42 -0
- package/tsconfig.json +35 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"mcp__agent-swarm__*",
|
|
5
|
+
"Bash(bun run tsc:*)"
|
|
6
|
+
]
|
|
7
|
+
},
|
|
8
|
+
"enableAllProjectMcpServers": true,
|
|
9
|
+
"enabledMcpjsonServers": [
|
|
10
|
+
"agent-swarm"
|
|
11
|
+
],
|
|
12
|
+
"hooks": {
|
|
13
|
+
"SessionStart": [
|
|
14
|
+
{
|
|
15
|
+
"matcher": "*",
|
|
16
|
+
"hooks": [
|
|
17
|
+
{
|
|
18
|
+
"type": "command",
|
|
19
|
+
"command": "bun run \"$CLAUDE_PROJECT_DIR\"/src/hooks/hook.ts"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"UserPromptSubmit": [
|
|
25
|
+
{
|
|
26
|
+
"matcher": "*",
|
|
27
|
+
"hooks": [
|
|
28
|
+
{
|
|
29
|
+
"type": "command",
|
|
30
|
+
"command": "bun run \"$CLAUDE_PROJECT_DIR\"/src/hooks/hook.ts"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"PreToolUse": [
|
|
36
|
+
{
|
|
37
|
+
"matcher": "*",
|
|
38
|
+
"hooks": [
|
|
39
|
+
{
|
|
40
|
+
"type": "command",
|
|
41
|
+
"command": "bun run \"$CLAUDE_PROJECT_DIR\"/src/hooks/hook.ts"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"PostToolUse": [
|
|
47
|
+
{
|
|
48
|
+
"matcher": "*",
|
|
49
|
+
"hooks": [
|
|
50
|
+
{
|
|
51
|
+
"type": "command",
|
|
52
|
+
"command": "bun run \"$CLAUDE_PROJECT_DIR\"/src/hooks/hook.ts"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"PreCompact": [
|
|
58
|
+
{
|
|
59
|
+
"matcher": "*",
|
|
60
|
+
"hooks": [
|
|
61
|
+
{
|
|
62
|
+
"type": "command",
|
|
63
|
+
"command": "bun run \"$CLAUDE_PROJECT_DIR\"/src/hooks/hook.ts"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"Stop": [
|
|
69
|
+
{
|
|
70
|
+
"matcher": "*",
|
|
71
|
+
"hooks": [
|
|
72
|
+
{
|
|
73
|
+
"type": "command",
|
|
74
|
+
"command": "bun run \"$CLAUDE_PROJECT_DIR\"/src/hooks/hook.ts"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
}
|
package/.editorconfig
ADDED
package/.env.example
ADDED
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Use Bun instead of Node.js, npm, pnpm, or vite.
|
|
3
|
+
globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Default to using Bun instead of Node.js.
|
|
8
|
+
|
|
9
|
+
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
|
|
10
|
+
- Use `bun test` instead of `jest` or `vitest`
|
|
11
|
+
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
|
|
12
|
+
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
|
|
13
|
+
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
|
|
14
|
+
- Bun automatically loads .env, so don't use dotenv.
|
|
15
|
+
|
|
16
|
+
## APIs
|
|
17
|
+
|
|
18
|
+
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
|
|
19
|
+
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
|
|
20
|
+
- `Bun.redis` for Redis. Don't use `ioredis`.
|
|
21
|
+
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
|
|
22
|
+
- `WebSocket` is built-in. Don't use `ws`.
|
|
23
|
+
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
|
|
24
|
+
- Bun.$`ls` instead of execa.
|
|
25
|
+
|
|
26
|
+
## Testing
|
|
27
|
+
|
|
28
|
+
Use `bun test` to run tests.
|
|
29
|
+
|
|
30
|
+
```ts#index.test.ts
|
|
31
|
+
import { test, expect } from "bun:test";
|
|
32
|
+
|
|
33
|
+
test("hello world", () => {
|
|
34
|
+
expect(1).toBe(1);
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Frontend
|
|
39
|
+
|
|
40
|
+
Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
|
|
41
|
+
|
|
42
|
+
Server:
|
|
43
|
+
|
|
44
|
+
```ts#index.ts
|
|
45
|
+
import index from "./index.html"
|
|
46
|
+
|
|
47
|
+
Bun.serve({
|
|
48
|
+
routes: {
|
|
49
|
+
"/": index,
|
|
50
|
+
"/api/users/:id": {
|
|
51
|
+
GET: (req) => {
|
|
52
|
+
return new Response(JSON.stringify({ id: req.params.id }));
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
// optional websocket support
|
|
57
|
+
websocket: {
|
|
58
|
+
open: (ws) => {
|
|
59
|
+
ws.send("Hello, world!");
|
|
60
|
+
},
|
|
61
|
+
message: (ws, message) => {
|
|
62
|
+
ws.send(message);
|
|
63
|
+
},
|
|
64
|
+
close: (ws) => {
|
|
65
|
+
// handle close
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
development: {
|
|
69
|
+
hmr: true,
|
|
70
|
+
console: true,
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
|
|
76
|
+
|
|
77
|
+
```html#index.html
|
|
78
|
+
<html>
|
|
79
|
+
<body>
|
|
80
|
+
<h1>Hello, world!</h1>
|
|
81
|
+
<script type="module" src="./frontend.tsx"></script>
|
|
82
|
+
</body>
|
|
83
|
+
</html>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
With the following `frontend.tsx`:
|
|
87
|
+
|
|
88
|
+
```tsx#frontend.tsx
|
|
89
|
+
import React from "react";
|
|
90
|
+
|
|
91
|
+
// import .css files directly and it works
|
|
92
|
+
import './index.css';
|
|
93
|
+
|
|
94
|
+
import { createRoot } from "react-dom/client";
|
|
95
|
+
|
|
96
|
+
const root = createRoot(document.body);
|
|
97
|
+
|
|
98
|
+
export default function Frontend() {
|
|
99
|
+
return <h1>Hello, world!</h1>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
root.render(<Frontend />);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Then, run index.ts
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
bun --hot ./index.ts
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.
|
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Agent Swarm MCP
|
|
2
|
+
|
|
3
|
+
> Agent orchestration layer MCP for Claude Code, Codex, Gemini CLI, and more!
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Agent Swarm MCP enables multi-agent coordination for AI coding assistants. It provides tools for agents to join a swarm, receive tasks, report progress, and coordinate with a lead agent.
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
### Setup (Recommended)
|
|
12
|
+
|
|
13
|
+
Run the setup command in your project directory:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bunx @desplega.ai/agent-swarm@latest setup
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This will:
|
|
20
|
+
- Create `.claude` directory and `settings.local.json` if needed
|
|
21
|
+
- Create `.mcp.json` if needed
|
|
22
|
+
- Add entries to `.gitignore`
|
|
23
|
+
- Configure permissions and hooks
|
|
24
|
+
- Prompt for your API token and Agent ID
|
|
25
|
+
|
|
26
|
+
Options:
|
|
27
|
+
- `--dry-run` - Preview changes without writing
|
|
28
|
+
- `--restore` - Restore files from `.bak` backups
|
|
29
|
+
|
|
30
|
+
### Manual Installation
|
|
31
|
+
|
|
32
|
+
Add to your `.mcp.json`:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"mcpServers": {
|
|
37
|
+
"agent-swarm": {
|
|
38
|
+
"type": "http",
|
|
39
|
+
"url": "https://agent-swarm-mcp.desplega.sh/mcp",
|
|
40
|
+
"headers": {
|
|
41
|
+
"Authorization": "Bearer <your-token>",
|
|
42
|
+
"X-Agent-ID": "<your-agent-id>"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## CLI Commands
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Run setup wizard
|
|
53
|
+
bunx @desplega.ai/agent-swarm setup
|
|
54
|
+
|
|
55
|
+
# Preview setup changes
|
|
56
|
+
bunx @desplega.ai/agent-swarm setup --dry-run
|
|
57
|
+
|
|
58
|
+
# Restore from backups
|
|
59
|
+
bunx @desplega.ai/agent-swarm setup --restore
|
|
60
|
+
|
|
61
|
+
# Start MCP HTTP server (for self-hosting)
|
|
62
|
+
bunx @desplega.ai/agent-swarm mcp
|
|
63
|
+
bunx @desplega.ai/agent-swarm mcp --port 8080 --key my-api-key
|
|
64
|
+
|
|
65
|
+
# Run Claude CLI with swarm integration
|
|
66
|
+
bunx @desplega.ai/agent-swarm claude
|
|
67
|
+
bunx @desplega.ai/agent-swarm claude --headless -m "Hello"
|
|
68
|
+
|
|
69
|
+
# Hook handler (called by Claude Code hooks)
|
|
70
|
+
bunx @desplega.ai/agent-swarm hook
|
|
71
|
+
|
|
72
|
+
# Show help
|
|
73
|
+
bunx @desplega.ai/agent-swarm help
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Environment Variables
|
|
77
|
+
|
|
78
|
+
| Variable | Description | Default |
|
|
79
|
+
|----------|-------------|---------|
|
|
80
|
+
| `MCP_BASE_URL` | Base URL for the MCP server | `https://agent-swarm-mcp.desplega.sh` |
|
|
81
|
+
| `PORT` | Port for self-hosted MCP server | `3013` |
|
|
82
|
+
| `API_KEY` | API key for server authentication | - |
|
|
83
|
+
|
|
84
|
+
## Development
|
|
85
|
+
|
|
86
|
+
Install dependencies:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
bun install
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Run the STDIO server:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
bun run start
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Run the HTTP server:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
bun run start:http
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Run with hot reload:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
bun run dev # STDIO
|
|
108
|
+
bun run dev:http # HTTP
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Run the MCP inspector:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
bun run inspector # STDIO
|
|
115
|
+
bun run inspector:http # HTTP
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Run the CLI locally:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
bun run cli setup
|
|
122
|
+
bun run cli setup --dry-run
|
|
123
|
+
bun run hook # Hook handler
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## MCP Tools
|
|
127
|
+
|
|
128
|
+
The server provides these tools for agent coordination:
|
|
129
|
+
|
|
130
|
+
- `join-swarm` - Register an agent in the swarm
|
|
131
|
+
- `poll-task` - Poll for assigned tasks (worker agents)
|
|
132
|
+
- `send-task` - Assign a task to an agent (lead agent)
|
|
133
|
+
- `get-swarm` - List all agents in the swarm
|
|
134
|
+
- `get-tasks` - List tasks filtered by status
|
|
135
|
+
- `get-task-details` - Get detailed info about a task
|
|
136
|
+
- `store-progress` - Update task progress or mark complete/failed
|
|
137
|
+
- `my-agent-info` - Get current agent's info
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
MIT License, 2025-2026 (c) desplega.ai
|
package/biome.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.3.9/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"ignoreUnknown": false
|
|
10
|
+
},
|
|
11
|
+
"formatter": {
|
|
12
|
+
"enabled": true,
|
|
13
|
+
"indentStyle": "space",
|
|
14
|
+
"indentWidth": 2,
|
|
15
|
+
"lineWidth": 100
|
|
16
|
+
},
|
|
17
|
+
"linter": {
|
|
18
|
+
"enabled": true,
|
|
19
|
+
"rules": {
|
|
20
|
+
"recommended": true
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"javascript": {
|
|
24
|
+
"formatter": {
|
|
25
|
+
"quoteStyle": "double"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"assist": {
|
|
29
|
+
"enabled": true,
|
|
30
|
+
"actions": {
|
|
31
|
+
"source": {
|
|
32
|
+
"organizeImports": "on"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"signal": {},
|
|
4
|
+
"sessionId": "942c8196-66ad-4c1f-b31e-7331ce7f4bb9",
|
|
5
|
+
"_meta": {
|
|
6
|
+
"progressToken": 3
|
|
7
|
+
},
|
|
8
|
+
"requestId": 3,
|
|
9
|
+
"requestInfo": {
|
|
10
|
+
"headers": {
|
|
11
|
+
"accept": "application/json, text/event-stream",
|
|
12
|
+
"accept-encoding": "gzip, deflate, br",
|
|
13
|
+
"authorization": "Bearer 123123",
|
|
14
|
+
"connection": "keep-alive",
|
|
15
|
+
"content-length": "119",
|
|
16
|
+
"content-type": "application/json",
|
|
17
|
+
"host": "localhost:3013",
|
|
18
|
+
"mcp-protocol-version": "2025-11-25",
|
|
19
|
+
"mcp-session-id": "942c8196-66ad-4c1f-b31e-7331ce7f4bb9",
|
|
20
|
+
"user-agent": "node-fetch"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@desplega.ai/agent-swarm",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Agent orchestration layer MCP for Claude Code, Codex, Gemini CLI, and more!",
|
|
5
|
+
"module": "src/stdio.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"agent-swarm": "./src/cli.tsx"
|
|
9
|
+
},
|
|
10
|
+
"@desplega.ai/agent-swarm": "link:@desplega.ai/agent-swarm",
|
|
11
|
+
"config": {
|
|
12
|
+
"name": "agent-swarm"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"tsc:check": "bun tsc --noEmit",
|
|
16
|
+
"cli": "bun src/cli.tsx",
|
|
17
|
+
"hook": "bun src/hooks/hook.ts",
|
|
18
|
+
"claude": "bun src/cli.tsx claude",
|
|
19
|
+
"claude:headless": "bun src/cli.tsx claude --headless",
|
|
20
|
+
"dev": "bun --hot src/stdio.ts",
|
|
21
|
+
"dev:http": "bun --hot src/http.ts",
|
|
22
|
+
"start": "bun src/stdio.ts",
|
|
23
|
+
"start:http": "bun src/http.ts",
|
|
24
|
+
"inspector": "bunx @modelcontextprotocol/inspector --transport stdio bun src/stdio.ts",
|
|
25
|
+
"inspector:http": "bunx @modelcontextprotocol/inspector --transport http http://localhost:3013/mcp",
|
|
26
|
+
"lint": "biome check src",
|
|
27
|
+
"lint:fix": "biome check --write src",
|
|
28
|
+
"format": "biome format --write src"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@biomejs/biome": "^2.3.9",
|
|
32
|
+
"@types/bun": "latest"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"typescript": "^5"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@inkjs/ui": "^2.0.0",
|
|
39
|
+
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
40
|
+
"@types/react": "^19.2.7",
|
|
41
|
+
"date-fns": "^4.1.0",
|
|
42
|
+
"ink": "^6.5.1",
|
|
43
|
+
"react": "^19.2.3",
|
|
44
|
+
"zod": "^4.2.1"
|
|
45
|
+
}
|
|
46
|
+
}
|