cursor-agent-a2a 1.0.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/LICENSE +21 -0
- package/README.md +306 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/routes/__tests__/cursorAgent.test.d.ts +14 -0
- package/dist/routes/__tests__/cursorAgent.test.d.ts.map +1 -0
- package/dist/routes/__tests__/cursorAgent.test.js +486 -0
- package/dist/routes/__tests__/cursorAgent.test.js.map +1 -0
- package/dist/routes/cursorAgent.d.ts +20 -0
- package/dist/routes/cursorAgent.d.ts.map +1 -0
- package/dist/routes/cursorAgent.js +722 -0
- package/dist/routes/cursorAgent.js.map +1 -0
- package/dist/services/__tests__/cursorAgentService.test.d.ts +12 -0
- package/dist/services/__tests__/cursorAgentService.test.d.ts.map +1 -0
- package/dist/services/__tests__/cursorAgentService.test.js +421 -0
- package/dist/services/__tests__/cursorAgentService.test.js.map +1 -0
- package/dist/services/cursorAgentService.d.ts +60 -0
- package/dist/services/cursorAgentService.d.ts.map +1 -0
- package/dist/services/cursorAgentService.js +392 -0
- package/dist/services/cursorAgentService.js.map +1 -0
- package/dist/types/a2a.d.ts +89 -0
- package/dist/types/a2a.d.ts.map +1 -0
- package/dist/types/a2a.js +7 -0
- package/dist/types/a2a.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jeffkit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
# Cursor Agent A2A Service
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/cursor-agent-a2a)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
Independent A2A-compatible service wrapping Cursor CLI agent command. This service provides a standard A2A (Agent-to-Agent) protocol interface for Cursor CLI, allowing it to be called from other A2A-compatible services like AgentStudio.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- ✅ **A2A Protocol Compliant** - Full support for A2A protocol endpoints
|
|
11
|
+
- ✅ **Multi-turn Conversations** - Session management with workspace persistence
|
|
12
|
+
- ✅ **Streaming Responses** - Server-Sent Events (SSE) for real-time updates
|
|
13
|
+
- ✅ **Async Task Management** - Long-running task support with status polling
|
|
14
|
+
- ✅ **Workspace Management** - Automatic workspace handling in multi-turn conversations
|
|
15
|
+
- ✅ **Session Persistence** - Workspace is automatically retrieved from session context
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### As a Standalone Service
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Clone the repository
|
|
23
|
+
git clone https://github.com/jeffkit/cursor-agent-a2a.git
|
|
24
|
+
cd cursor-agent-a2a
|
|
25
|
+
|
|
26
|
+
# Install dependencies
|
|
27
|
+
pnpm install
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### As an NPM Package
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install cursor-agent-a2a
|
|
34
|
+
# or
|
|
35
|
+
pnpm add cursor-agent-a2a
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Prerequisites
|
|
39
|
+
|
|
40
|
+
### Cursor CLI Setup
|
|
41
|
+
|
|
42
|
+
Make sure Cursor CLI is installed and authenticated:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Install Cursor CLI
|
|
46
|
+
curl https://cursor.com/install -fsS | bash
|
|
47
|
+
|
|
48
|
+
# Login (or set CURSOR_API_KEY environment variable)
|
|
49
|
+
cursor agent login
|
|
50
|
+
|
|
51
|
+
# Verify authentication
|
|
52
|
+
cursor agent status
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
Set environment variables:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# API Key for A2A authentication (default: cursor-agent-demo-key)
|
|
61
|
+
export CURSOR_AGENT_API_KEY=your-secure-api-key
|
|
62
|
+
|
|
63
|
+
# Server port (default: 4937)
|
|
64
|
+
export PORT=4937
|
|
65
|
+
|
|
66
|
+
# Server host (default: 0.0.0.0)
|
|
67
|
+
export HOST=0.0.0.0
|
|
68
|
+
|
|
69
|
+
# Cursor API Key (optional, uses local login if not set)
|
|
70
|
+
export CURSOR_API_KEY=sk_your_cursor_api_key
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Running
|
|
74
|
+
|
|
75
|
+
### Development Mode
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pnpm run dev
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Production Mode
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Build
|
|
85
|
+
pnpm run build
|
|
86
|
+
|
|
87
|
+
# Start
|
|
88
|
+
pnpm start
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The service will start on `http://localhost:4937` (or your configured port).
|
|
92
|
+
|
|
93
|
+
## API Endpoints
|
|
94
|
+
|
|
95
|
+
All endpoints require API key authentication via `Authorization: Bearer <api-key>` header.
|
|
96
|
+
|
|
97
|
+
### Agent Card Discovery
|
|
98
|
+
|
|
99
|
+
Get the agent's capabilities and metadata.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
GET /.well-known/agent-card.json
|
|
103
|
+
Authorization: Bearer <api-key>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Response:**
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"name": "Cursor Agent",
|
|
110
|
+
"description": "AI-powered code assistant via Cursor CLI...",
|
|
111
|
+
"version": "1.0.0",
|
|
112
|
+
"url": "http://localhost:4937",
|
|
113
|
+
"skills": [...],
|
|
114
|
+
"securitySchemes": [...]
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Send Message (Synchronous)
|
|
119
|
+
|
|
120
|
+
Send a message and get an immediate response.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
POST /messages
|
|
124
|
+
Authorization: Bearer <api-key>
|
|
125
|
+
Content-Type: application/json
|
|
126
|
+
|
|
127
|
+
{
|
|
128
|
+
"message": "Say hello",
|
|
129
|
+
"workspace": "/path/to/project",
|
|
130
|
+
"sessionId": "optional-session-id"
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Response:**
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"response": "Hello! I'm Claude, an AI programming assistant...",
|
|
138
|
+
"sessionId": "chat-12345",
|
|
139
|
+
"metadata": {
|
|
140
|
+
"processingTimeMs": 1234
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Streaming Mode:**
|
|
146
|
+
|
|
147
|
+
Add `?stream=true` or `Accept: text/event-stream` header:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
POST /messages?stream=true
|
|
151
|
+
Authorization: Bearer <api-key>
|
|
152
|
+
Accept: text/event-stream
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Create Async Task
|
|
156
|
+
|
|
157
|
+
Create a long-running task and poll for status.
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
POST /tasks
|
|
161
|
+
Authorization: Bearer <api-key>
|
|
162
|
+
Content-Type: application/json
|
|
163
|
+
|
|
164
|
+
{
|
|
165
|
+
"message": "Long running task",
|
|
166
|
+
"workspace": "/path/to/project",
|
|
167
|
+
"timeout": 600000,
|
|
168
|
+
"sessionId": "optional-session-id"
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Response:**
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"taskId": "task-uuid",
|
|
176
|
+
"status": "pending",
|
|
177
|
+
"checkUrl": "/tasks/task-uuid"
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Query Task Status
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
GET /tasks/:taskId
|
|
185
|
+
Authorization: Bearer <api-key>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Response:**
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"taskId": "task-uuid",
|
|
192
|
+
"status": "completed",
|
|
193
|
+
"output": {
|
|
194
|
+
"result": "Task completed successfully"
|
|
195
|
+
},
|
|
196
|
+
"createdAt": "2026-01-24T...",
|
|
197
|
+
"completedAt": "2026-01-24T..."
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Cancel Task
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
DELETE /tasks/:taskId
|
|
205
|
+
Authorization: Bearer <api-key>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Multi-turn Conversations
|
|
209
|
+
|
|
210
|
+
The service supports multi-turn conversations with automatic workspace management:
|
|
211
|
+
|
|
212
|
+
1. **First message** - Provide `workspace` parameter:
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"message": "Create a hello.js file",
|
|
216
|
+
"workspace": "/path/to/project"
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
Response includes `sessionId`.
|
|
220
|
+
|
|
221
|
+
2. **Subsequent messages** - Only need `sessionId`, workspace is automatically retrieved:
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"message": "Modify the file to add a function",
|
|
225
|
+
"sessionId": "chat-12345"
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Usage Examples
|
|
230
|
+
|
|
231
|
+
### Using with AgentStudio
|
|
232
|
+
|
|
233
|
+
Add to your project's `a2a-config.json`:
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"allowedAgents": [
|
|
238
|
+
{
|
|
239
|
+
"name": "Cursor Agent",
|
|
240
|
+
"url": "http://localhost:4937",
|
|
241
|
+
"apiKey": "your-api-key",
|
|
242
|
+
"description": "Cursor CLI agent via A2A",
|
|
243
|
+
"enabled": true
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Then use it in AgentStudio agents via the A2A client tool.
|
|
250
|
+
|
|
251
|
+
### Using with curl
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Get agent card
|
|
255
|
+
curl -X GET "http://localhost:4937/.well-known/agent-card.json" \
|
|
256
|
+
-H "Authorization: Bearer your-api-key"
|
|
257
|
+
|
|
258
|
+
# Send message
|
|
259
|
+
curl -X POST "http://localhost:4937/messages" \
|
|
260
|
+
-H "Authorization: Bearer your-api-key" \
|
|
261
|
+
-H "Content-Type: application/json" \
|
|
262
|
+
-d '{
|
|
263
|
+
"message": "Say hello",
|
|
264
|
+
"workspace": "/path/to/project"
|
|
265
|
+
}'
|
|
266
|
+
|
|
267
|
+
# Continue conversation
|
|
268
|
+
curl -X POST "http://localhost:4937/messages" \
|
|
269
|
+
-H "Authorization: Bearer your-api-key" \
|
|
270
|
+
-H "Content-Type: application/json" \
|
|
271
|
+
-d '{
|
|
272
|
+
"message": "Continue",
|
|
273
|
+
"sessionId": "chat-12345"
|
|
274
|
+
}'
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Development
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# Type checking
|
|
281
|
+
pnpm run type-check
|
|
282
|
+
|
|
283
|
+
# Build
|
|
284
|
+
pnpm run build
|
|
285
|
+
|
|
286
|
+
# Development with hot reload
|
|
287
|
+
pnpm run dev
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## License
|
|
291
|
+
|
|
292
|
+
MIT
|
|
293
|
+
|
|
294
|
+
## Author
|
|
295
|
+
|
|
296
|
+
jeffkit (bbmyth@gmail.com)
|
|
297
|
+
|
|
298
|
+
## Contributing
|
|
299
|
+
|
|
300
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
301
|
+
|
|
302
|
+
## Links
|
|
303
|
+
|
|
304
|
+
- [GitHub Repository](https://github.com/jeffkit/cursor-agent-a2a)
|
|
305
|
+
- [NPM Package](https://www.npmjs.com/package/cursor-agent-a2a)
|
|
306
|
+
- [Cursor CLI Documentation](https://cursor.com/docs/cli)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor Agent A2A Service - Independent Service
|
|
3
|
+
*
|
|
4
|
+
* Standalone A2A-compatible service wrapping Cursor CLI agent command.
|
|
5
|
+
* Can be run independently or called from other services like AgentStudio.
|
|
6
|
+
*/
|
|
7
|
+
import express from 'express';
|
|
8
|
+
import cors from 'cors';
|
|
9
|
+
import dotenv from 'dotenv';
|
|
10
|
+
import cursorAgentRouter from './routes/cursorAgent.js';
|
|
11
|
+
dotenv.config();
|
|
12
|
+
const app = express();
|
|
13
|
+
const PORT = Number(process.env.PORT) || 4937;
|
|
14
|
+
const HOST = process.env.HOST || '0.0.0.0';
|
|
15
|
+
// Middleware
|
|
16
|
+
app.use(cors());
|
|
17
|
+
app.use(express.json({ limit: '10mb' }));
|
|
18
|
+
app.use(express.urlencoded({ extended: true, limit: '10mb' }));
|
|
19
|
+
// Health check
|
|
20
|
+
app.get('/health', (req, res) => {
|
|
21
|
+
res.json({
|
|
22
|
+
status: 'ok',
|
|
23
|
+
timestamp: new Date().toISOString(),
|
|
24
|
+
service: 'cursor-agent-a2a',
|
|
25
|
+
version: '1.0.0',
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
// A2A Protocol routes
|
|
29
|
+
app.use('/', cursorAgentRouter);
|
|
30
|
+
// Start server
|
|
31
|
+
app.listen(PORT, HOST, () => {
|
|
32
|
+
console.log(`🚀 Cursor Agent A2A Service running on http://${HOST}:${PORT}`);
|
|
33
|
+
console.log(`📋 Agent Card: http://${HOST}:${PORT}/.well-known/agent-card.json`);
|
|
34
|
+
console.log(`💬 Messages: http://${HOST}:${PORT}/messages`);
|
|
35
|
+
console.log(`📦 Tasks: http://${HOST}:${PORT}/tasks`);
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;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,GAAG,CAAC,yBAAyB,IAAI,IAAI,IAAI,8BAA8B,CAAC,CAAC;IACjF,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,IAAI,IAAI,WAAW,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,IAAI,IAAI,QAAQ,CAAC,CAAC;AACxD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for cursorAgent.ts - Cursor Agent A2A Routes
|
|
3
|
+
*
|
|
4
|
+
* Tests cover:
|
|
5
|
+
* - Homepage endpoint
|
|
6
|
+
* - Agent Card discovery
|
|
7
|
+
* - Message endpoints (sync and streaming)
|
|
8
|
+
* - Task management (create, query, cancel)
|
|
9
|
+
* - Authentication
|
|
10
|
+
* - Session management
|
|
11
|
+
* - Webhook callbacks
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=cursorAgent.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursorAgent.test.d.ts","sourceRoot":"","sources":["../../../src/routes/__tests__/cursorAgent.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|