n8n-nodes-cursor-agent 2.1.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 +152 -0
- package/dist/credentials/CursorApi.credentials.js +31 -0
- package/dist/credentials/CursorApi.credentials.js.map +1 -0
- package/dist/credentials/cursor.svg +1 -0
- package/dist/nodes/CursorAgent/CursorAgent.node.js +479 -0
- package/dist/nodes/CursorAgent/CursorAgent.node.js.map +1 -0
- package/dist/nodes/CursorAgent/cursor.svg +1 -0
- package/dist/nodes/CursorAgent/lib/assistantTimeline.js +180 -0
- package/dist/nodes/CursorAgent/lib/assistantTimeline.js.map +1 -0
- package/dist/nodes/CursorAgent/lib/cursorMessageMeta.js +70 -0
- package/dist/nodes/CursorAgent/lib/cursorMessageMeta.js.map +1 -0
- package/dist/nodes/CursorAgent/lib/cursorStreamProtocol.js +383 -0
- package/dist/nodes/CursorAgent/lib/cursorStreamProtocol.js.map +1 -0
- package/dist/nodes/CursorAgent/lib/parseMcpServers.js +190 -0
- package/dist/nodes/CursorAgent/lib/parseMcpServers.js.map +1 -0
- package/dist/nodes/CursorAgent/lib/resolveApiKey.js +14 -0
- package/dist/nodes/CursorAgent/lib/resolveApiKey.js.map +1 -0
- package/dist/nodes/CursorAgent/lib/resolveLocalCwd.js +35 -0
- package/dist/nodes/CursorAgent/lib/resolveLocalCwd.js.map +1 -0
- package/dist/nodes/CursorAgent/lib/sessionStore.js +42 -0
- package/dist/nodes/CursorAgent/lib/sessionStore.js.map +1 -0
- package/dist/nodes/CursorAgent/lib/streamAdapter.js +260 -0
- package/dist/nodes/CursorAgent/lib/streamAdapter.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 liuhuayao
|
|
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,152 @@
|
|
|
1
|
+
# n8n-nodes-cursor-agent
|
|
2
|
+
|
|
3
|
+
面向 **n8n** 的社区节点包:**Cursor Agent**。通过 [`@cursor/sdk`](https://cursor.com/docs/sdk/typescript) 在本机 **local runtime** 运行 Cursor Agent,支持配置 MCP 服务器、Skills 工作目录与 Redis 多轮会话。
|
|
4
|
+
|
|
5
|
+
- **npm:** [`n8n-nodes-cursor-agent`](https://www.npmjs.com/package/n8n-nodes-cursor-agent)
|
|
6
|
+
- **源码:** <https://github.com/liuhauyao/n8n-nodes-cursor-agent>
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 前置条件
|
|
11
|
+
|
|
12
|
+
| 项 | 说明 |
|
|
13
|
+
|----|------|
|
|
14
|
+
| Node.js | `>= 22.16`(与 n8n 运行环境一致) |
|
|
15
|
+
| Cursor API Key | 在 n8n 中配置 **Cursor API** 凭证,或设置环境变量 `CURSOR_API_KEY` |
|
|
16
|
+
| Redis | 节点要求配置 n8n 内置 **Redis** 凭证(用于 `sessionId` → `agentId` 映射) |
|
|
17
|
+
| 本机 Cursor CLI | local runtime 需在 n8n 进程所在机器上可运行 Cursor Agent |
|
|
18
|
+
|
|
19
|
+
**当前限制:** 仅支持 **local runtime**,不支持 cloud agent。
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 安装
|
|
24
|
+
|
|
25
|
+
### n8n 社区节点 UI
|
|
26
|
+
|
|
27
|
+
Settings → Community Nodes → Install → 输入 `n8n-nodes-cursor-agent`
|
|
28
|
+
|
|
29
|
+
### Docker / 自托管
|
|
30
|
+
|
|
31
|
+
在 `N8N_COMMUNITY_PACKAGES` 或 `package.json` 中加入依赖后重启 n8n。
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 节点参数
|
|
36
|
+
|
|
37
|
+
| 参数 | 说明 |
|
|
38
|
+
|------|------|
|
|
39
|
+
| **System Message** | 首轮与 User Message 拼接;resume 已有会话时忽略 |
|
|
40
|
+
| **User Message** | 必填,当前轮用户输入 |
|
|
41
|
+
| **Session ID** | 可选;非空时通过 Redis 恢复同一 Cursor agent |
|
|
42
|
+
| **Skills Root Directory** | 可选;含 `.cursor/skills/` 的目录,作为 `local.cwd` 数组第一项 |
|
|
43
|
+
| **Working Directories** | 一个或多个绝对路径,映射为 `local.cwd: string[]` |
|
|
44
|
+
| **Working Directory (legacy)** | 兼容 2.0.0 单目录;与上述字段合并去重 |
|
|
45
|
+
| **Setting Sources** | 从本地加载 Cursor 设置层,默认 `project`(加载 cwd 下 `.cursor/`) |
|
|
46
|
+
| **Model** | 动态从 `Cursor.models.list()` 加载,失败时回退静态列表 |
|
|
47
|
+
| **Additional Options → MCP Servers** | 表单配置 HTTP / SSE / stdio MCP |
|
|
48
|
+
| **Additional Options → MCP Servers JSON** | JSON 对象,**非空时覆盖表单** |
|
|
49
|
+
| **Additional Options → Session TTL** | Redis 键 TTL(秒),默认 604800 |
|
|
50
|
+
|
|
51
|
+
### Skills
|
|
52
|
+
|
|
53
|
+
将 skill 放在工作目录下的 `.cursor/skills/<skill-name>/SKILL.md`,并把 **Setting Sources** 包含 `project`(默认已选)。
|
|
54
|
+
|
|
55
|
+
**Skills Root Directory** 应指向含 `.cursor/skills/` 的仓库根;它会作为 `local.cwd` 的第一项,确保 skill 从指定根加载。
|
|
56
|
+
|
|
57
|
+
### 多工作目录示例
|
|
58
|
+
|
|
59
|
+
跨前后端仓库检索时:
|
|
60
|
+
|
|
61
|
+
| 参数 | 值 |
|
|
62
|
+
|------|-----|
|
|
63
|
+
| Skills Root Directory | `/data/workspace/frontend` |
|
|
64
|
+
| Working Directories | `/data/workspace/frontend`、`/data/workspace/backend` |
|
|
65
|
+
|
|
66
|
+
SDK 收到 `local.cwd: [frontend, frontend, backend]` 去重后为 `[frontend, backend]`。
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## MCP 配置示例
|
|
71
|
+
|
|
72
|
+
### 表单(HTTP)
|
|
73
|
+
|
|
74
|
+
- Name: `my-api`
|
|
75
|
+
- Transport: HTTP
|
|
76
|
+
- URL: `https://example.com/mcp`
|
|
77
|
+
- Headers: `Authorization` = `Bearer <token>`
|
|
78
|
+
|
|
79
|
+
### JSON 覆盖
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"my-api": {
|
|
84
|
+
"type": "http",
|
|
85
|
+
"url": "https://example.com/mcp",
|
|
86
|
+
"headers": { "Authorization": "Bearer xxx" }
|
|
87
|
+
},
|
|
88
|
+
"local-tool": {
|
|
89
|
+
"type": "stdio",
|
|
90
|
+
"command": "npx",
|
|
91
|
+
"args": ["-y", "some-mcp-server"]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Inline MCP 在 **create、resume、send** 时均需传入;本节点已自动处理。
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 输出字段
|
|
101
|
+
|
|
102
|
+
| 字段 | 说明 |
|
|
103
|
+
|------|------|
|
|
104
|
+
| `output` | 带 `<cursor_meta>` 的完整输出(含 timeline / suggestions) |
|
|
105
|
+
| `textOutput` | 纯 Markdown 正文 |
|
|
106
|
+
| `model` | 使用的模型 id |
|
|
107
|
+
| `agentId` | Cursor agent id |
|
|
108
|
+
| `runId` | 本次 run id |
|
|
109
|
+
| `sessionId` | 回传输入的 session id |
|
|
110
|
+
|
|
111
|
+
### 流式事件(`__cursor__`)
|
|
112
|
+
|
|
113
|
+
启用 n8n 流式响应时,节点通过 `sendChunk` 输出 JSON 行,marker 为 `__cursor__`:
|
|
114
|
+
|
|
115
|
+
| kind | 含义 |
|
|
116
|
+
|------|------|
|
|
117
|
+
| `thinking_start` / `thinking_chunk` / `thinking_end` | 思考过程 |
|
|
118
|
+
| `text` | 正文增量 |
|
|
119
|
+
| `tool_start` / `tool_end` | 工具调用 |
|
|
120
|
+
| `ask_question` | AskQuestion 工具参数 |
|
|
121
|
+
| `todo_update` | Todo 列表更新 |
|
|
122
|
+
| `status` | 任务状态 |
|
|
123
|
+
| `awaiting_input` | 等待用户输入 |
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 本地 POC
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
export CURSOR_API_KEY=...
|
|
131
|
+
export POC_CWD=/path/to/your/project
|
|
132
|
+
export POC_MCP_SERVERS_JSON='{"demo":{"type":"http","url":"https://example.com/mcp"}}'
|
|
133
|
+
npm run poc
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 开发
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
npm install
|
|
142
|
+
npm run verify # build + eslint + package.json lint
|
|
143
|
+
npm run dev # tsc --watch
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 相关文档
|
|
149
|
+
|
|
150
|
+
- [Cursor SDK (TypeScript)](https://cursor.com/docs/sdk/typescript)
|
|
151
|
+
- [Cursor MCP](https://cursor.com/docs/mcp)
|
|
152
|
+
- [n8n Community Nodes](https://docs.n8n.io/integrations/community-nodes/)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CursorApi = void 0;
|
|
4
|
+
class CursorApi {
|
|
5
|
+
name = 'cursorApi';
|
|
6
|
+
displayName = 'Cursor API';
|
|
7
|
+
icon = 'file:cursor.svg';
|
|
8
|
+
documentationUrl = 'https://cursor.com/docs/sdk/typescript';
|
|
9
|
+
properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'API Key',
|
|
12
|
+
name: 'apiKey',
|
|
13
|
+
type: 'string',
|
|
14
|
+
typeOptions: { password: true },
|
|
15
|
+
required: true,
|
|
16
|
+
default: '',
|
|
17
|
+
description: 'Cursor user or service account API key (CURSOR_API_KEY)',
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
test = {
|
|
21
|
+
request: {
|
|
22
|
+
baseURL: 'https://api.cursor.com',
|
|
23
|
+
url: '/v0/me',
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: '=Bearer {{$credentials.apiKey}}',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.CursorApi = CursorApi;
|
|
31
|
+
//# sourceMappingURL=CursorApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CursorApi.credentials.js","sourceRoot":"","sources":["../../credentials/CursorApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;IACrB,IAAI,GAAG,WAAW,CAAC;IAEnB,WAAW,GAAG,YAAY,CAAC;IAE3B,IAAI,GAAS,iBAAiB,CAAC;IAE/B,gBAAgB,GAAG,wCAAwC,CAAC;IAE5D,UAAU,GAAsB;QAC/B;YACC,WAAW,EAAE,SAAS;YACtB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,yDAAyD;SACtE;KACD,CAAC;IAEF,IAAI,GAA2B;QAC9B,OAAO,EAAE;YACR,OAAO,EAAE,wBAAwB;YACjC,GAAG,EAAE,QAAQ;YACb,OAAO,EAAE;gBACR,aAAa,EAAE,iCAAiC;aAChD;SACD;KACD,CAAC;CACF;AA9BD,8BA8BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="40" height="40" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Cursor</title><path fill="#55544F" d="M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z"></path></svg>
|