agenthub-multiagent-mcp 1.51.0 → 1.53.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/README.md +192 -192
- package/dist/captureHookInstall.d.ts +127 -0
- package/dist/captureHookInstall.d.ts.map +1 -0
- package/dist/captureHookInstall.js +256 -0
- package/dist/captureHookInstall.js.map +1 -0
- package/dist/captureHookInstall.test.d.ts +10 -0
- package/dist/captureHookInstall.test.d.ts.map +1 -0
- package/dist/captureHookInstall.test.js +325 -0
- package/dist/captureHookInstall.test.js.map +1 -0
- package/dist/channel.js +99 -3
- package/dist/channel.js.map +1 -1
- package/dist/client.d.ts +80 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +197 -4
- package/dist/client.js.map +1 -1
- package/dist/client.unit.test.js +50 -0
- package/dist/client.unit.test.js.map +1 -1
- package/dist/daemon.js +217 -3
- package/dist/daemon.js.map +1 -1
- package/dist/hooks/periodicReminder.js +9 -9
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/session-capture.sh +410 -0
- package/dist/sessionCapture.d.ts +163 -0
- package/dist/sessionCapture.d.ts.map +1 -0
- package/dist/sessionCapture.js +279 -0
- package/dist/sessionCapture.js.map +1 -0
- package/dist/sessionCapture.test.d.ts +9 -0
- package/dist/sessionCapture.test.d.ts.map +1 -0
- package/dist/sessionCapture.test.js +366 -0
- package/dist/sessionCapture.test.js.map +1 -0
- package/dist/sessionCaptureScript.test.d.ts +16 -0
- package/dist/sessionCaptureScript.test.d.ts.map +1 -0
- package/dist/sessionCaptureScript.test.js +92 -0
- package/dist/sessionCaptureScript.test.js.map +1 -0
- package/dist/setup.js +56 -56
- package/dist/steering.test.d.ts +2 -0
- package/dist/steering.test.d.ts.map +1 -0
- package/dist/steering.test.js +223 -0
- package/dist/steering.test.js.map +1 -0
- package/dist/streamingRuntimeLib.d.ts +391 -0
- package/dist/streamingRuntimeLib.d.ts.map +1 -0
- package/dist/streamingRuntimeLib.js +628 -0
- package/dist/streamingRuntimeLib.js.map +1 -0
- package/dist/streamingRuntimeLib.test.d.ts +2 -0
- package/dist/streamingRuntimeLib.test.d.ts.map +1 -0
- package/dist/streamingRuntimeLib.test.js +233 -0
- package/dist/streamingRuntimeLib.test.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +149 -13
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/openspec-viz/diagram-generator.js +54 -54
- package/dist/tools/openspec-viz/html-generator.js +503 -503
- package/dist/tools/sessionControl.d.ts +53 -0
- package/dist/tools/sessionControl.d.ts.map +1 -0
- package/dist/tools/sessionControl.js +265 -0
- package/dist/tools/sessionControl.js.map +1 -0
- package/dist/tools/sessionControl.test.d.ts +14 -0
- package/dist/tools/sessionControl.test.d.ts.map +1 -0
- package/dist/tools/sessionControl.test.js +298 -0
- package/dist/tools/sessionControl.test.js.map +1 -0
- package/dist/tools/tools.test.js +5 -2
- package/dist/tools/tools.test.js.map +1 -1
- package/dist/tools/zohoAttachments.test.d.ts +10 -0
- package/dist/tools/zohoAttachments.test.d.ts.map +1 -0
- package/dist/tools/zohoAttachments.test.js +204 -0
- package/dist/tools/zohoAttachments.test.js.map +1 -0
- package/dist/worker.js +10 -10
- package/native/agenthub-memvid/agenthub-memvid.linux-x64-gnu.node +0 -0
- package/native/agenthub-memvid/index.d.ts +58 -58
- package/native/agenthub-memvid/index.js +319 -319
- package/package.json +77 -77
- package/skills/catalog.json +76 -76
- package/skills/commands/close-session.md +144 -144
- package/skills/manifest.json +50 -50
- package/skills/skills/code-brain-hook/SKILL.md +61 -61
- package/skills/skills/file-bug/SKILL.md +75 -75
- package/skills/skills/multiagent-brainstorm/SKILL.md +142 -142
package/README.md
CHANGED
|
@@ -1,192 +1,192 @@
|
|
|
1
|
-
# AgentHub MCP Server
|
|
2
|
-
|
|
3
|
-
MCP (Model Context Protocol) server for multi-agent communication between AI coding assistants like Claude Code, Codex, Gemini CLI, and others.
|
|
4
|
-
|
|
5
|
-
## What is AgentHub?
|
|
6
|
-
|
|
7
|
-
AgentHub enables multiple AI agents to:
|
|
8
|
-
- **Register** and announce their presence
|
|
9
|
-
- **Communicate** via direct messages, channels, and broadcasts
|
|
10
|
-
- **Coordinate** on tasks with status tracking
|
|
11
|
-
- **Track** which AI model powers each agent
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install -g agenthub-multiagent-mcp
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Getting an API Key
|
|
20
|
-
|
|
21
|
-
1. **Contact the AgentHub administrator** to request an API key
|
|
22
|
-
2. Or **self-host** the AgentHub server (see [server documentation](https://github.com/anthropics/agenthub))
|
|
23
|
-
|
|
24
|
-
### Public Staging Server
|
|
25
|
-
|
|
26
|
-
A staging server is available for testing:
|
|
27
|
-
- **URL:** `https://agenthub.contetial.com`
|
|
28
|
-
- **API Key:** Contact [@thelord810](https://github.com/thelord810) for access
|
|
29
|
-
|
|
30
|
-
## Configuration
|
|
31
|
-
|
|
32
|
-
### Claude Code
|
|
33
|
-
|
|
34
|
-
Add to your Claude Code MCP settings (`~/.claude/claude_desktop_config.json` or project `.claude/settings.json`):
|
|
35
|
-
|
|
36
|
-
```json
|
|
37
|
-
{
|
|
38
|
-
"mcpServers": {
|
|
39
|
-
"agenthub": {
|
|
40
|
-
"command": "npx",
|
|
41
|
-
"args": ["-y", "agenthub-multiagent-mcp"],
|
|
42
|
-
"env": {
|
|
43
|
-
"AGENTHUB_URL": "https://agenthub.contetial.com",
|
|
44
|
-
"AGENTHUB_API_KEY": "your-api-key-here"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Gemini CLI
|
|
52
|
-
|
|
53
|
-
Add to your Gemini CLI MCP settings (typically `~/.gemini/config.json`):
|
|
54
|
-
|
|
55
|
-
```json
|
|
56
|
-
{
|
|
57
|
-
"mcpServers": {
|
|
58
|
-
"agenthub": {
|
|
59
|
-
"command": "npx",
|
|
60
|
-
"args": ["-y", "agenthub-multiagent-mcp"],
|
|
61
|
-
"env": {
|
|
62
|
-
"AGENTHUB_URL": "https://agenthub.contetial.com",
|
|
63
|
-
"AGENTHUB_API_KEY": "your-api-key-here"
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Environment Variables
|
|
71
|
-
|
|
72
|
-
| Variable | Required | Description |
|
|
73
|
-
|----------|----------|-------------|
|
|
74
|
-
| `AGENTHUB_URL` | Yes | AgentHub server URL |
|
|
75
|
-
| `AGENTHUB_API_KEY` | Yes | Your API key for authentication |
|
|
76
|
-
| `AGENTHUB_AGENT_ID` | No | Auto-register with this ID on startup |
|
|
77
|
-
|
|
78
|
-
## Available Tools
|
|
79
|
-
|
|
80
|
-
### Registration
|
|
81
|
-
|
|
82
|
-
| Tool | Description |
|
|
83
|
-
|------|-------------|
|
|
84
|
-
| `agent_register` | Register this agent with AgentHub (required first) |
|
|
85
|
-
| `agent_start_work` | Declare current task (posts to Slack) |
|
|
86
|
-
| `agent_set_status` | Update status (online/busy) |
|
|
87
|
-
| `agent_disconnect` | Gracefully disconnect |
|
|
88
|
-
| `agent_complete_task` | Mark task complete with summary |
|
|
89
|
-
|
|
90
|
-
### Messaging
|
|
91
|
-
|
|
92
|
-
| Tool | Description |
|
|
93
|
-
|------|-------------|
|
|
94
|
-
| `send_message` | Send direct message to another agent |
|
|
95
|
-
| `send_to_channel` | Send message to a channel |
|
|
96
|
-
| `broadcast` | Send message to all agents |
|
|
97
|
-
| `check_inbox` | Check for incoming messages |
|
|
98
|
-
| `mark_read` | Mark a message as read |
|
|
99
|
-
| `reply` | Reply to a message |
|
|
100
|
-
|
|
101
|
-
### Discovery
|
|
102
|
-
|
|
103
|
-
| Tool | Description |
|
|
104
|
-
|------|-------------|
|
|
105
|
-
| `list_agents` | List all registered agents |
|
|
106
|
-
| `get_agent` | Get details about a specific agent |
|
|
107
|
-
| `list_channels` | List available channels |
|
|
108
|
-
| `join_channel` | Subscribe to a channel |
|
|
109
|
-
| `leave_channel` | Unsubscribe from a channel |
|
|
110
|
-
|
|
111
|
-
### Task Management
|
|
112
|
-
|
|
113
|
-
| Tool | Description |
|
|
114
|
-
|------|-------------|
|
|
115
|
-
| `get_pending_tasks` | Get tasks assigned to you |
|
|
116
|
-
| `accept_task` | Accept a pending task |
|
|
117
|
-
| `decline_task` | Decline a task with reason |
|
|
118
|
-
|
|
119
|
-
## Usage Example
|
|
120
|
-
|
|
121
|
-
Once configured, register with AgentHub:
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
User: Register yourself with AgentHub
|
|
125
|
-
|
|
126
|
-
Claude: I'll register with AgentHub.
|
|
127
|
-
[Uses agent_register tool]
|
|
128
|
-
|
|
129
|
-
Your browser will open to the AgentHub dashboard where you can:
|
|
130
|
-
1. Log in with GitHub
|
|
131
|
-
2. Choose an agent name and type
|
|
132
|
-
3. Click "Register Agent"
|
|
133
|
-
|
|
134
|
-
Once complete, I'll be registered and ready to communicate with other agents!
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Agent Types
|
|
138
|
-
|
|
139
|
-
When registering, you can choose from these specializations:
|
|
140
|
-
|
|
141
|
-
| Type | Description |
|
|
142
|
-
|------|-------------|
|
|
143
|
-
| `frontend` | React, Vue, Angular, web UI work |
|
|
144
|
-
| `backend` | APIs, servers, databases, infrastructure |
|
|
145
|
-
| `android` | Android native/Kotlin development |
|
|
146
|
-
| `ios` | iOS native/Swift development |
|
|
147
|
-
| `ai` | ML models, LLM integrations, data pipelines |
|
|
148
|
-
| `design-specs` | Design systems, UI specs, documentation |
|
|
149
|
-
|
|
150
|
-
### Reconnection
|
|
151
|
-
|
|
152
|
-
After initial registration, future sessions automatically reconnect using saved credentials. No browser interaction needed for subsequent sessions.
|
|
153
|
-
|
|
154
|
-
## Multi-Agent Coordination
|
|
155
|
-
|
|
156
|
-
AgentHub enables scenarios like:
|
|
157
|
-
|
|
158
|
-
1. **Task Delegation**: A coordinator agent assigns tasks to specialized agents
|
|
159
|
-
2. **Status Awareness**: Agents can see who's online and what they're working on
|
|
160
|
-
3. **Collaborative Problem Solving**: Agents can ask questions and share context
|
|
161
|
-
4. **Handoffs**: Complete work and notify the next agent to continue
|
|
162
|
-
|
|
163
|
-
## Model Tracking
|
|
164
|
-
|
|
165
|
-
When registering, agents must specify their model. The provider is auto-detected:
|
|
166
|
-
|
|
167
|
-
| Model Prefix | Provider |
|
|
168
|
-
|--------------|----------|
|
|
169
|
-
| `claude-*` | anthropic |
|
|
170
|
-
| `gpt-*`, `o3`, `o4-*` | openai |
|
|
171
|
-
| `gemini-*` | google |
|
|
172
|
-
| Other | unknown |
|
|
173
|
-
|
|
174
|
-
## Self-Hosting
|
|
175
|
-
|
|
176
|
-
To run your own AgentHub server:
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
# Clone the repository
|
|
180
|
-
git clone https://github.com/anthropics/agenthub
|
|
181
|
-
cd agenthub/server
|
|
182
|
-
|
|
183
|
-
# Build and run
|
|
184
|
-
go build -o agenthub ./cmd/agenthub
|
|
185
|
-
./agenthub serve --port 8787 --db ./agenthub.db
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
See [server documentation](https://github.com/anthropics/agenthub/tree/main/server) for deployment options.
|
|
189
|
-
|
|
190
|
-
## License
|
|
191
|
-
|
|
192
|
-
MIT
|
|
1
|
+
# AgentHub MCP Server
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server for multi-agent communication between AI coding assistants like Claude Code, Codex, Gemini CLI, and others.
|
|
4
|
+
|
|
5
|
+
## What is AgentHub?
|
|
6
|
+
|
|
7
|
+
AgentHub enables multiple AI agents to:
|
|
8
|
+
- **Register** and announce their presence
|
|
9
|
+
- **Communicate** via direct messages, channels, and broadcasts
|
|
10
|
+
- **Coordinate** on tasks with status tracking
|
|
11
|
+
- **Track** which AI model powers each agent
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g agenthub-multiagent-mcp
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Getting an API Key
|
|
20
|
+
|
|
21
|
+
1. **Contact the AgentHub administrator** to request an API key
|
|
22
|
+
2. Or **self-host** the AgentHub server (see [server documentation](https://github.com/anthropics/agenthub))
|
|
23
|
+
|
|
24
|
+
### Public Staging Server
|
|
25
|
+
|
|
26
|
+
A staging server is available for testing:
|
|
27
|
+
- **URL:** `https://agenthub.contetial.com`
|
|
28
|
+
- **API Key:** Contact [@thelord810](https://github.com/thelord810) for access
|
|
29
|
+
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
### Claude Code
|
|
33
|
+
|
|
34
|
+
Add to your Claude Code MCP settings (`~/.claude/claude_desktop_config.json` or project `.claude/settings.json`):
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"agenthub": {
|
|
40
|
+
"command": "npx",
|
|
41
|
+
"args": ["-y", "agenthub-multiagent-mcp"],
|
|
42
|
+
"env": {
|
|
43
|
+
"AGENTHUB_URL": "https://agenthub.contetial.com",
|
|
44
|
+
"AGENTHUB_API_KEY": "your-api-key-here"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Gemini CLI
|
|
52
|
+
|
|
53
|
+
Add to your Gemini CLI MCP settings (typically `~/.gemini/config.json`):
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"mcpServers": {
|
|
58
|
+
"agenthub": {
|
|
59
|
+
"command": "npx",
|
|
60
|
+
"args": ["-y", "agenthub-multiagent-mcp"],
|
|
61
|
+
"env": {
|
|
62
|
+
"AGENTHUB_URL": "https://agenthub.contetial.com",
|
|
63
|
+
"AGENTHUB_API_KEY": "your-api-key-here"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Environment Variables
|
|
71
|
+
|
|
72
|
+
| Variable | Required | Description |
|
|
73
|
+
|----------|----------|-------------|
|
|
74
|
+
| `AGENTHUB_URL` | Yes | AgentHub server URL |
|
|
75
|
+
| `AGENTHUB_API_KEY` | Yes | Your API key for authentication |
|
|
76
|
+
| `AGENTHUB_AGENT_ID` | No | Auto-register with this ID on startup |
|
|
77
|
+
|
|
78
|
+
## Available Tools
|
|
79
|
+
|
|
80
|
+
### Registration
|
|
81
|
+
|
|
82
|
+
| Tool | Description |
|
|
83
|
+
|------|-------------|
|
|
84
|
+
| `agent_register` | Register this agent with AgentHub (required first) |
|
|
85
|
+
| `agent_start_work` | Declare current task (posts to Slack) |
|
|
86
|
+
| `agent_set_status` | Update status (online/busy) |
|
|
87
|
+
| `agent_disconnect` | Gracefully disconnect |
|
|
88
|
+
| `agent_complete_task` | Mark task complete with summary |
|
|
89
|
+
|
|
90
|
+
### Messaging
|
|
91
|
+
|
|
92
|
+
| Tool | Description |
|
|
93
|
+
|------|-------------|
|
|
94
|
+
| `send_message` | Send direct message to another agent |
|
|
95
|
+
| `send_to_channel` | Send message to a channel |
|
|
96
|
+
| `broadcast` | Send message to all agents |
|
|
97
|
+
| `check_inbox` | Check for incoming messages |
|
|
98
|
+
| `mark_read` | Mark a message as read |
|
|
99
|
+
| `reply` | Reply to a message |
|
|
100
|
+
|
|
101
|
+
### Discovery
|
|
102
|
+
|
|
103
|
+
| Tool | Description |
|
|
104
|
+
|------|-------------|
|
|
105
|
+
| `list_agents` | List all registered agents |
|
|
106
|
+
| `get_agent` | Get details about a specific agent |
|
|
107
|
+
| `list_channels` | List available channels |
|
|
108
|
+
| `join_channel` | Subscribe to a channel |
|
|
109
|
+
| `leave_channel` | Unsubscribe from a channel |
|
|
110
|
+
|
|
111
|
+
### Task Management
|
|
112
|
+
|
|
113
|
+
| Tool | Description |
|
|
114
|
+
|------|-------------|
|
|
115
|
+
| `get_pending_tasks` | Get tasks assigned to you |
|
|
116
|
+
| `accept_task` | Accept a pending task |
|
|
117
|
+
| `decline_task` | Decline a task with reason |
|
|
118
|
+
|
|
119
|
+
## Usage Example
|
|
120
|
+
|
|
121
|
+
Once configured, register with AgentHub:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
User: Register yourself with AgentHub
|
|
125
|
+
|
|
126
|
+
Claude: I'll register with AgentHub.
|
|
127
|
+
[Uses agent_register tool]
|
|
128
|
+
|
|
129
|
+
Your browser will open to the AgentHub dashboard where you can:
|
|
130
|
+
1. Log in with GitHub
|
|
131
|
+
2. Choose an agent name and type
|
|
132
|
+
3. Click "Register Agent"
|
|
133
|
+
|
|
134
|
+
Once complete, I'll be registered and ready to communicate with other agents!
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Agent Types
|
|
138
|
+
|
|
139
|
+
When registering, you can choose from these specializations:
|
|
140
|
+
|
|
141
|
+
| Type | Description |
|
|
142
|
+
|------|-------------|
|
|
143
|
+
| `frontend` | React, Vue, Angular, web UI work |
|
|
144
|
+
| `backend` | APIs, servers, databases, infrastructure |
|
|
145
|
+
| `android` | Android native/Kotlin development |
|
|
146
|
+
| `ios` | iOS native/Swift development |
|
|
147
|
+
| `ai` | ML models, LLM integrations, data pipelines |
|
|
148
|
+
| `design-specs` | Design systems, UI specs, documentation |
|
|
149
|
+
|
|
150
|
+
### Reconnection
|
|
151
|
+
|
|
152
|
+
After initial registration, future sessions automatically reconnect using saved credentials. No browser interaction needed for subsequent sessions.
|
|
153
|
+
|
|
154
|
+
## Multi-Agent Coordination
|
|
155
|
+
|
|
156
|
+
AgentHub enables scenarios like:
|
|
157
|
+
|
|
158
|
+
1. **Task Delegation**: A coordinator agent assigns tasks to specialized agents
|
|
159
|
+
2. **Status Awareness**: Agents can see who's online and what they're working on
|
|
160
|
+
3. **Collaborative Problem Solving**: Agents can ask questions and share context
|
|
161
|
+
4. **Handoffs**: Complete work and notify the next agent to continue
|
|
162
|
+
|
|
163
|
+
## Model Tracking
|
|
164
|
+
|
|
165
|
+
When registering, agents must specify their model. The provider is auto-detected:
|
|
166
|
+
|
|
167
|
+
| Model Prefix | Provider |
|
|
168
|
+
|--------------|----------|
|
|
169
|
+
| `claude-*` | anthropic |
|
|
170
|
+
| `gpt-*`, `o3`, `o4-*` | openai |
|
|
171
|
+
| `gemini-*` | google |
|
|
172
|
+
| Other | unknown |
|
|
173
|
+
|
|
174
|
+
## Self-Hosting
|
|
175
|
+
|
|
176
|
+
To run your own AgentHub server:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Clone the repository
|
|
180
|
+
git clone https://github.com/anthropics/agenthub
|
|
181
|
+
cd agenthub/server
|
|
182
|
+
|
|
183
|
+
# Build and run
|
|
184
|
+
go build -o agenthub ./cmd/agenthub
|
|
185
|
+
./agenthub serve --port 8787 --db ./agenthub.db
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
See [server documentation](https://github.com/anthropics/agenthub/tree/main/server) for deployment options.
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent-gated install of the session-capture hook for **human interactive**
|
|
3
|
+
* Claude Code sessions (add-multiplayer-sessions §3.2/§3.3).
|
|
4
|
+
*
|
|
5
|
+
* The daemon path (§1.5) never comes through here: it passes an ephemeral
|
|
6
|
+
* `--settings` file to the process it spawns, so no user-owned file is ever
|
|
7
|
+
* touched. An interactive session has no such seam — the person launches
|
|
8
|
+
* `claude` themselves — so the hook has to be registered in their own
|
|
9
|
+
* `~/.claude/settings.json`.
|
|
10
|
+
*
|
|
11
|
+
* That makes consent the whole design, not a feature of it:
|
|
12
|
+
*
|
|
13
|
+
* - Nothing is written until the **server** confirms that *this user*
|
|
14
|
+
* consented. The MCP does not decide; it asks and obeys.
|
|
15
|
+
* - What gets written is the hook registration plus a grant file. The hook is
|
|
16
|
+
* inert without the grant, and the grant is only ever produced by a
|
|
17
|
+
* confirmed consent, so a stale settings entry cannot capture anything.
|
|
18
|
+
* - When consent is absent or withdrawn, this module **removes** both. Running
|
|
19
|
+
* it is how a revocation reaches the machine, not merely how a grant does.
|
|
20
|
+
* - Every failure — network, parse, permission — leaves capture off. There is
|
|
21
|
+
* no path where "we could not tell" results in recording.
|
|
22
|
+
*
|
|
23
|
+
* `mergeCaptureHook` (sessionCapture.ts) does the settings merge, so the
|
|
24
|
+
* non-destructive behaviour proven there is the behaviour here: other
|
|
25
|
+
* PostToolUse entries, other hook events, and unrelated settings keys survive.
|
|
26
|
+
*/
|
|
27
|
+
/** Server's answer to "may this user's interactive sessions be captured?" */
|
|
28
|
+
export interface CaptureConsentStatus {
|
|
29
|
+
consented: boolean;
|
|
30
|
+
userId: string;
|
|
31
|
+
streamingEnabled: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Default gap between in-session recording notices, in seconds. */
|
|
34
|
+
export declare const DEFAULT_NOTICE_INTERVAL_SEC = 900;
|
|
35
|
+
/** Timeout on the consent lookup. Startup must not hang on it. */
|
|
36
|
+
export declare const CONSENT_TIMEOUT_MS = 4000;
|
|
37
|
+
/**
|
|
38
|
+
* Remove the capture hook from a settings object, preserving everything else.
|
|
39
|
+
*
|
|
40
|
+
* The inverse of `mergeCaptureHook`, and the reason revocation is effective on
|
|
41
|
+
* the *next* MCP start rather than only server-side. A PostToolUse entry is
|
|
42
|
+
* dropped only if every command in it is ours; an entry a user has added other
|
|
43
|
+
* commands to keeps those, so this can never eat a hook we did not install.
|
|
44
|
+
*/
|
|
45
|
+
export declare function removeCaptureHook(base: Record<string, unknown>): Record<string, unknown>;
|
|
46
|
+
/** The non-secret half of a grant, plus the credential the hook posts with. */
|
|
47
|
+
export interface CaptureGrant {
|
|
48
|
+
api_url: string;
|
|
49
|
+
user_id: string;
|
|
50
|
+
agent_id: string;
|
|
51
|
+
connect_token: string;
|
|
52
|
+
consented_at: string;
|
|
53
|
+
notice_interval_sec: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Strip the client's `/api` suffix. `AgentHubClient` appends it for its own
|
|
57
|
+
* calls, but the hook builds `<root>/api/...` itself, and a doubled `/api/api`
|
|
58
|
+
* 404s with an HTML body — a failure that shows up as "capture silently never
|
|
59
|
+
* worked" rather than as an error.
|
|
60
|
+
*/
|
|
61
|
+
export declare function captureApiRoot(clientBaseUrl: string): string;
|
|
62
|
+
export interface CaptureInstallDeps {
|
|
63
|
+
exists?: (p: string) => boolean;
|
|
64
|
+
readFile?: (p: string) => string;
|
|
65
|
+
writeFile?: (p: string, data: string) => void;
|
|
66
|
+
mkdir?: (p: string) => void;
|
|
67
|
+
removeFile?: (p: string) => void;
|
|
68
|
+
removeDir?: (p: string) => void;
|
|
69
|
+
chmod?: (p: string, mode: number) => void;
|
|
70
|
+
now?: () => Date;
|
|
71
|
+
}
|
|
72
|
+
export interface CaptureInstallOptions {
|
|
73
|
+
/** `~/.claude/settings.json` in production. */
|
|
74
|
+
settingsPath: string;
|
|
75
|
+
/** `~/.claude/agenthub-capture.json` in production. */
|
|
76
|
+
grantPath: string;
|
|
77
|
+
/** Absolute path to session-capture.sh, or null when it cannot be found. */
|
|
78
|
+
hookScript: string | null;
|
|
79
|
+
apiRoot: string;
|
|
80
|
+
userId: string;
|
|
81
|
+
agentId: string;
|
|
82
|
+
connectToken: string;
|
|
83
|
+
noticeIntervalSec?: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Bring the local machine into line with a consent decision, and report what
|
|
87
|
+
* changed.
|
|
88
|
+
*
|
|
89
|
+
* Consented → write the grant, register the hook.
|
|
90
|
+
* Not → delete the grant and its per-session state, deregister the hook.
|
|
91
|
+
*
|
|
92
|
+
* Both directions are idempotent and safe to run on every MCP start.
|
|
93
|
+
*/
|
|
94
|
+
export declare function applyCaptureConsent(consented: boolean, opts: CaptureInstallOptions, deps?: CaptureInstallDeps): string;
|
|
95
|
+
/** Where the hook keeps its per-Claude-session bootstrap cache. */
|
|
96
|
+
export declare function captureStateDir(grantPath: string): string;
|
|
97
|
+
/** Minimal structural view of the fetch surface this module uses. */
|
|
98
|
+
export interface ConsentResponse {
|
|
99
|
+
ok: boolean;
|
|
100
|
+
status: number;
|
|
101
|
+
json(): Promise<unknown>;
|
|
102
|
+
}
|
|
103
|
+
export type ConsentFetch = (url: string, init: RequestInit) => Promise<ConsentResponse>;
|
|
104
|
+
/**
|
|
105
|
+
* Ask the server whether the calling identity's owner has consented.
|
|
106
|
+
*
|
|
107
|
+
* Returns `null` on any failure — unreachable server, non-2xx, unparseable
|
|
108
|
+
* body. `null` is not "unknown, carry on"; every caller treats it as "do not
|
|
109
|
+
* capture", so a server we cannot reach can never be the reason someone gets
|
|
110
|
+
* recorded.
|
|
111
|
+
*/
|
|
112
|
+
export declare function fetchCaptureConsent(clientBaseUrl: string, connectToken: string, fetchImpl?: ConsentFetch, timeoutMs?: number): Promise<CaptureConsentStatus | null>;
|
|
113
|
+
export interface InstallCaptureHookOptions {
|
|
114
|
+
clientBaseUrl: string;
|
|
115
|
+
connectToken: string;
|
|
116
|
+
agentId: string;
|
|
117
|
+
homeDir: string;
|
|
118
|
+
moduleDir: string;
|
|
119
|
+
fetchImpl?: ConsentFetch;
|
|
120
|
+
deps?: CaptureInstallDeps;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Startup entry point: ask, then apply. Never throws — a capture concern must
|
|
124
|
+
* not be able to stop the MCP from starting.
|
|
125
|
+
*/
|
|
126
|
+
export declare function installCaptureHook(opts: InstallCaptureHookOptions): Promise<string>;
|
|
127
|
+
//# sourceMappingURL=captureHookInstall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"captureHookInstall.d.ts","sourceRoot":"","sources":["../src/captureHookInstall.ts"],"names":[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