@jnymmt/n8n-nodes-claudecode 0.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.md +19 -0
- package/README.md +247 -0
- package/dist/nodes/ClaudeCode/ClaudeCode.node.d.ts +5 -0
- package/dist/nodes/ClaudeCode/ClaudeCode.node.js +395 -0
- package/dist/nodes/ClaudeCode/ClaudeCode.node.js.map +1 -0
- package/dist/nodes/ClaudeCode/ClaudeCode.node.json +17 -0
- package/dist/nodes/ClaudeCode/claude.svg +4 -0
- package/dist/nodes/ClaudeCode/types.d.ts +68 -0
- package/dist/nodes/ClaudeCode/types.js +3 -0
- package/dist/nodes/ClaudeCode/types.js.map +1 -0
- package/dist/nodes/ClaudeCode/utils/commandBuilder.d.ts +2 -0
- package/dist/nodes/ClaudeCode/utils/commandBuilder.js +144 -0
- package/dist/nodes/ClaudeCode/utils/commandBuilder.js.map +1 -0
- package/dist/nodes/ClaudeCode/utils/outputParser.d.ts +2 -0
- package/dist/nodes/ClaudeCode/utils/outputParser.js +88 -0
- package/dist/nodes/ClaudeCode/utils/outputParser.js.map +1 -0
- package/dist/nodes/ClaudeCode/utils/processRunner.d.ts +3 -0
- package/dist/nodes/ClaudeCode/utils/processRunner.js +94 -0
- package/dist/nodes/ClaudeCode/utils/processRunner.js.map +1 -0
- package/dist/package.json +52 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +52 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright 2022 n8n
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# n8n-nodes-starter
|
|
4
|
+
|
|
5
|
+
This starter repository helps you build custom integrations for [n8n](https://n8n.io). It includes example nodes, credentials, the node linter, and all the tooling you need to get started.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
> [!TIP]
|
|
10
|
+
> **New to building n8n nodes?** The fastest way to get started is with `npm create @n8n/node`. This command scaffolds a complete node package for you using the [@n8n/node-cli](https://www.npmjs.com/package/@n8n/node-cli).
|
|
11
|
+
|
|
12
|
+
**To create a new node package from scratch:**
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm create @n8n/node
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Already using this starter? Start developing with:**
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm run dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This starts n8n with your nodes loaded and hot reload enabled.
|
|
25
|
+
|
|
26
|
+
## What's Included
|
|
27
|
+
|
|
28
|
+
This starter repository includes two example nodes to learn from:
|
|
29
|
+
|
|
30
|
+
- **[Example Node](nodes/Example/)** - A simple starter node that shows the basic structure with a custom `execute` method
|
|
31
|
+
- **[GitHub Issues Node](nodes/GithubIssues/)** - A complete, production-ready example built using the **declarative style**:
|
|
32
|
+
- **Low-code approach** - Define operations declaratively without writing request logic
|
|
33
|
+
- Multiple resources (Issues, Comments)
|
|
34
|
+
- Multiple operations (Get, Get All, Create)
|
|
35
|
+
- Two authentication methods (OAuth2 and Personal Access Token)
|
|
36
|
+
- List search functionality for dynamic dropdowns
|
|
37
|
+
- Proper error handling and typing
|
|
38
|
+
- Ideal for HTTP API-based integrations
|
|
39
|
+
|
|
40
|
+
> [!TIP]
|
|
41
|
+
> The declarative/low-code style (used in GitHub Issues) is the recommended approach for building nodes that interact with HTTP APIs. It significantly reduces boilerplate code and handles requests automatically.
|
|
42
|
+
|
|
43
|
+
Browse these examples to understand both approaches, then modify them or create your own.
|
|
44
|
+
|
|
45
|
+
## Finding Inspiration
|
|
46
|
+
|
|
47
|
+
Looking for more examples? Check out these resources:
|
|
48
|
+
|
|
49
|
+
- **[npm Community Nodes](https://www.npmjs.com/search?q=keywords:n8n-community-node-package)** - Browse thousands of community-built nodes on npm using the `n8n-community-node-package` tag
|
|
50
|
+
- **[n8n Built-in Nodes](https://github.com/n8n-io/n8n/tree/master/packages/nodes-base/nodes)** - Study the source code of n8n's official nodes for production-ready patterns and best practices
|
|
51
|
+
- **[n8n Credentials](https://github.com/n8n-io/n8n/tree/master/packages/nodes-base/credentials)** - See how authentication is implemented for various services
|
|
52
|
+
|
|
53
|
+
These are excellent resources to understand how to structure your nodes, handle different API patterns, and implement advanced features.
|
|
54
|
+
|
|
55
|
+
## Prerequisites
|
|
56
|
+
|
|
57
|
+
Before you begin, install the following on your development machine:
|
|
58
|
+
|
|
59
|
+
### Required
|
|
60
|
+
|
|
61
|
+
- **[Node.js](https://nodejs.org/)** (v22 or higher) and npm
|
|
62
|
+
- Linux/Mac/WSL: Install via [nvm](https://github.com/nvm-sh/nvm)
|
|
63
|
+
- Windows: Follow [Microsoft's NodeJS guide](https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-windows)
|
|
64
|
+
- **[git](https://git-scm.com/downloads)**
|
|
65
|
+
|
|
66
|
+
### Recommended
|
|
67
|
+
|
|
68
|
+
- Follow n8n's [development environment setup guide](https://docs.n8n.io/integrations/creating-nodes/build/node-development-environment/)
|
|
69
|
+
|
|
70
|
+
> [!NOTE]
|
|
71
|
+
> The `@n8n/node-cli` is included as a dev dependency and will be installed automatically when you run `npm install`. The CLI includes n8n for local development, so you don't need to install n8n globally.
|
|
72
|
+
|
|
73
|
+
## Getting Started with this Starter
|
|
74
|
+
|
|
75
|
+
Follow these steps to create your own n8n community node package:
|
|
76
|
+
|
|
77
|
+
### 1. Create Your Repository
|
|
78
|
+
|
|
79
|
+
[Generate a new repository](https://github.com/n8n-io/n8n-nodes-starter/generate) from this template, then clone it:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
git clone https://github.com/<your-organization>/<your-repo-name>.git
|
|
83
|
+
cd <your-repo-name>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2. Install Dependencies
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm install
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This installs all required dependencies including the `@n8n/node-cli`.
|
|
93
|
+
|
|
94
|
+
### 3. Explore the Examples
|
|
95
|
+
|
|
96
|
+
Browse the example nodes in [nodes/](nodes/) and [credentials/](credentials/) to understand the structure:
|
|
97
|
+
|
|
98
|
+
- Start with [nodes/Example/](nodes/Example/) for a basic node
|
|
99
|
+
- Study [nodes/GithubIssues/](nodes/GithubIssues/) for a real-world implementation
|
|
100
|
+
|
|
101
|
+
### 4. Build Your Node
|
|
102
|
+
|
|
103
|
+
Edit the example nodes to fit your use case, or create new node files by copying the structure from [nodes/Example/](nodes/Example/).
|
|
104
|
+
|
|
105
|
+
> [!TIP]
|
|
106
|
+
> If you want to scaffold a completely new node package, use `npm create @n8n/node` to start fresh with the CLI's interactive generator.
|
|
107
|
+
|
|
108
|
+
### 5. Configure Your Package
|
|
109
|
+
|
|
110
|
+
Update `package.json` with your details:
|
|
111
|
+
|
|
112
|
+
- `name` - Your package name (must start with `n8n-nodes-`)
|
|
113
|
+
- `author` - Your name and email
|
|
114
|
+
- `repository` - Your repository URL
|
|
115
|
+
- `description` - What your node does
|
|
116
|
+
|
|
117
|
+
Make sure your node is registered in the `n8n.nodes` array.
|
|
118
|
+
|
|
119
|
+
### 6. Develop and Test Locally
|
|
120
|
+
|
|
121
|
+
Start n8n with your node loaded:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm run dev
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
This command runs `n8n-node dev` which:
|
|
128
|
+
|
|
129
|
+
- Builds your node with watch mode
|
|
130
|
+
- Starts n8n with your node available
|
|
131
|
+
- Automatically rebuilds when you make changes
|
|
132
|
+
- Opens n8n in your browser (usually http://localhost:5678)
|
|
133
|
+
|
|
134
|
+
You can now test your node in n8n workflows!
|
|
135
|
+
|
|
136
|
+
> [!NOTE]
|
|
137
|
+
> Learn more about CLI commands in the [@n8n/node-cli documentation](https://www.npmjs.com/package/@n8n/node-cli).
|
|
138
|
+
|
|
139
|
+
### 7. Lint Your Code
|
|
140
|
+
|
|
141
|
+
Check for errors:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm run lint
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Auto-fix issues when possible:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npm run lint:fix
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 8. Build for Production
|
|
154
|
+
|
|
155
|
+
When ready to publish:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
npm run build
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
This compiles your TypeScript code to the `dist/` folder.
|
|
162
|
+
|
|
163
|
+
### 9. Prepare for Publishing
|
|
164
|
+
|
|
165
|
+
Before publishing:
|
|
166
|
+
|
|
167
|
+
1. **Update documentation**: Replace this README with your node's documentation. Use [README_TEMPLATE.md](README_TEMPLATE.md) as a starting point.
|
|
168
|
+
2. **Update the LICENSE**: Add your details to the [LICENSE](LICENSE.md) file.
|
|
169
|
+
3. **Test thoroughly**: Ensure your node works in different scenarios.
|
|
170
|
+
|
|
171
|
+
### 10. Publish to npm
|
|
172
|
+
|
|
173
|
+
Publish your package to make it available to the n8n community:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
npm publish
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Learn more about [publishing to npm](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry).
|
|
180
|
+
|
|
181
|
+
### 11. Submit for Verification (Optional)
|
|
182
|
+
|
|
183
|
+
Get your node verified for n8n Cloud:
|
|
184
|
+
|
|
185
|
+
1. Ensure your node meets the [requirements](https://docs.n8n.io/integrations/creating-nodes/deploy/submit-community-nodes/):
|
|
186
|
+
- Uses MIT license ✅ (included in this starter)
|
|
187
|
+
- No external package dependencies
|
|
188
|
+
- Follows n8n's design guidelines
|
|
189
|
+
- Passes quality and security review
|
|
190
|
+
|
|
191
|
+
2. Submit through the [n8n Creator Portal](https://creators.n8n.io/nodes)
|
|
192
|
+
|
|
193
|
+
**Benefits of verification:**
|
|
194
|
+
|
|
195
|
+
- Available directly in n8n Cloud
|
|
196
|
+
- Discoverable in the n8n nodes panel
|
|
197
|
+
- Verified badge for quality assurance
|
|
198
|
+
- Increased visibility in the n8n community
|
|
199
|
+
|
|
200
|
+
## Available Scripts
|
|
201
|
+
|
|
202
|
+
This starter includes several npm scripts to streamline development:
|
|
203
|
+
|
|
204
|
+
| Script | Description |
|
|
205
|
+
| --------------------- | ---------------------------------------------------------------- |
|
|
206
|
+
| `npm run dev` | Start n8n with your node and watch for changes (runs `n8n-node dev`) |
|
|
207
|
+
| `npm run build` | Compile TypeScript to JavaScript for production (runs `n8n-node build`) |
|
|
208
|
+
| `npm run build:watch` | Build in watch mode (auto-rebuild on changes) |
|
|
209
|
+
| `npm run lint` | Check your code for errors and style issues (runs `n8n-node lint`) |
|
|
210
|
+
| `npm run lint:fix` | Automatically fix linting issues when possible (runs `n8n-node lint --fix`) |
|
|
211
|
+
| `npm run release` | Create a new release (runs `n8n-node release`) |
|
|
212
|
+
|
|
213
|
+
> [!TIP]
|
|
214
|
+
> These scripts use the [@n8n/node-cli](https://www.npmjs.com/package/@n8n/node-cli) under the hood. You can also run CLI commands directly, e.g., `npx n8n-node dev`.
|
|
215
|
+
|
|
216
|
+
## Troubleshooting
|
|
217
|
+
|
|
218
|
+
### My node doesn't appear in n8n
|
|
219
|
+
|
|
220
|
+
1. Make sure you ran `npm install` to install dependencies
|
|
221
|
+
2. Check that your node is listed in `package.json` under `n8n.nodes`
|
|
222
|
+
3. Restart the dev server with `npm run dev`
|
|
223
|
+
4. Check the console for any error messages
|
|
224
|
+
|
|
225
|
+
### Linting errors
|
|
226
|
+
|
|
227
|
+
Run `npm run lint:fix` to automatically fix most common issues. For remaining errors, check the [n8n node development guidelines](https://docs.n8n.io/integrations/creating-nodes/).
|
|
228
|
+
|
|
229
|
+
### TypeScript errors
|
|
230
|
+
|
|
231
|
+
Make sure you're using Node.js v22 or higher and have run `npm install` to get all type definitions.
|
|
232
|
+
|
|
233
|
+
## Resources
|
|
234
|
+
|
|
235
|
+
- **[n8n Node Documentation](https://docs.n8n.io/integrations/creating-nodes/)** - Complete guide to building nodes
|
|
236
|
+
- **[n8n Community Forum](https://community.n8n.io/)** - Get help and share your nodes
|
|
237
|
+
- **[@n8n/node-cli Documentation](https://www.npmjs.com/package/@n8n/node-cli)** - CLI tool reference
|
|
238
|
+
- **[n8n Creator Portal](https://creators.n8n.io/nodes)** - Submit your node for verification
|
|
239
|
+
- **[Submit Community Nodes Guide](https://docs.n8n.io/integrations/creating-nodes/deploy/submit-community-nodes/)** - Verification requirements and process
|
|
240
|
+
|
|
241
|
+
## Contributing
|
|
242
|
+
|
|
243
|
+
Have suggestions for improving this starter? [Open an issue](https://github.com/n8n-io/n8n-nodes-starter/issues) or submit a pull request!
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
[MIT](https://github.com/n8n-io/n8n-nodes-starter/blob/master/LICENSE.md)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class ClaudeCode implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClaudeCode = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const commandBuilder_1 = require("./utils/commandBuilder");
|
|
6
|
+
const processRunner_1 = require("./utils/processRunner");
|
|
7
|
+
const outputParser_1 = require("./utils/outputParser");
|
|
8
|
+
class ClaudeCode {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.description = {
|
|
11
|
+
displayName: 'Claude Code',
|
|
12
|
+
name: 'claudeCode',
|
|
13
|
+
icon: 'file:claude.svg',
|
|
14
|
+
group: ['transform'],
|
|
15
|
+
version: 1,
|
|
16
|
+
subtitle: '={{$parameter["model"] || "default"}}',
|
|
17
|
+
description: 'Execute Claude Code CLI for AI-powered coding tasks',
|
|
18
|
+
defaults: {
|
|
19
|
+
name: 'Claude Code',
|
|
20
|
+
},
|
|
21
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
22
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
23
|
+
usableAsTool: true,
|
|
24
|
+
properties: [
|
|
25
|
+
{
|
|
26
|
+
displayName: 'Prompt',
|
|
27
|
+
name: 'prompt',
|
|
28
|
+
type: 'string',
|
|
29
|
+
typeOptions: {
|
|
30
|
+
rows: 4,
|
|
31
|
+
},
|
|
32
|
+
default: '',
|
|
33
|
+
required: true,
|
|
34
|
+
description: 'The prompt to send to Claude Code',
|
|
35
|
+
placeholder: 'e.g., Analyze this code and suggest improvements',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
displayName: 'Working Directory',
|
|
39
|
+
name: 'workingDirectory',
|
|
40
|
+
type: 'string',
|
|
41
|
+
default: '',
|
|
42
|
+
description: 'Working directory for Claude Code (leave empty to use n8n working directory)',
|
|
43
|
+
placeholder: '/path/to/project',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
displayName: 'Model',
|
|
47
|
+
name: 'model',
|
|
48
|
+
type: 'options',
|
|
49
|
+
options: [
|
|
50
|
+
{ name: 'Custom', value: 'custom' },
|
|
51
|
+
{ name: 'Default', value: '' },
|
|
52
|
+
{ name: 'Haiku', value: 'haiku' },
|
|
53
|
+
{ name: 'Opus', value: 'opus' },
|
|
54
|
+
{ name: 'Sonnet', value: 'sonnet' },
|
|
55
|
+
],
|
|
56
|
+
default: '',
|
|
57
|
+
description: 'Claude model to use',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
displayName: 'Custom Model',
|
|
61
|
+
name: 'customModel',
|
|
62
|
+
type: 'string',
|
|
63
|
+
default: '',
|
|
64
|
+
displayOptions: {
|
|
65
|
+
show: {
|
|
66
|
+
model: ['custom'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
description: 'Custom model name (e.g., claude-sonnet-4-20250514)',
|
|
70
|
+
placeholder: 'claude-sonnet-4-20250514',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
displayName: 'System Prompt Mode',
|
|
74
|
+
name: 'systemPromptMode',
|
|
75
|
+
type: 'options',
|
|
76
|
+
options: [
|
|
77
|
+
{ name: 'None', value: 'none' },
|
|
78
|
+
{ name: 'Append', value: 'append' },
|
|
79
|
+
{ name: 'Replace', value: 'replace' },
|
|
80
|
+
],
|
|
81
|
+
default: 'none',
|
|
82
|
+
description: 'How to handle system prompt',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
displayName: 'System Prompt',
|
|
86
|
+
name: 'systemPrompt',
|
|
87
|
+
type: 'string',
|
|
88
|
+
typeOptions: {
|
|
89
|
+
rows: 4,
|
|
90
|
+
},
|
|
91
|
+
default: '',
|
|
92
|
+
displayOptions: {
|
|
93
|
+
show: {
|
|
94
|
+
systemPromptMode: ['append', 'replace'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
description: 'System prompt content',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
displayName: 'Session Mode',
|
|
101
|
+
name: 'sessionMode',
|
|
102
|
+
type: 'options',
|
|
103
|
+
options: [
|
|
104
|
+
{ name: 'New Session', value: 'new' },
|
|
105
|
+
{ name: 'Continue Last', value: 'continue' },
|
|
106
|
+
{ name: 'Resume Specific', value: 'resume' },
|
|
107
|
+
],
|
|
108
|
+
default: 'new',
|
|
109
|
+
description: 'Session management mode',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
displayName: 'Session ID',
|
|
113
|
+
name: 'sessionId',
|
|
114
|
+
type: 'string',
|
|
115
|
+
default: '',
|
|
116
|
+
displayOptions: {
|
|
117
|
+
show: {
|
|
118
|
+
sessionMode: ['resume'],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
description: 'Session ID to resume',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
displayName: 'Fork Session',
|
|
125
|
+
name: 'forkSession',
|
|
126
|
+
type: 'boolean',
|
|
127
|
+
default: false,
|
|
128
|
+
displayOptions: {
|
|
129
|
+
show: {
|
|
130
|
+
sessionMode: ['resume'],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
description: 'Whether to fork the session instead of resuming it',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
displayName: 'Tool Control',
|
|
137
|
+
name: 'toolControl',
|
|
138
|
+
type: 'options',
|
|
139
|
+
options: [
|
|
140
|
+
{ name: 'Allow List', value: 'allow' },
|
|
141
|
+
{ name: 'Custom', value: 'custom' },
|
|
142
|
+
{ name: 'Default', value: 'default' },
|
|
143
|
+
{ name: 'Deny List', value: 'deny' },
|
|
144
|
+
{ name: 'None', value: 'none' },
|
|
145
|
+
{ name: 'Preset', value: 'preset' },
|
|
146
|
+
],
|
|
147
|
+
default: 'default',
|
|
148
|
+
description: 'How to control tool usage',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
displayName: 'Tool Preset',
|
|
152
|
+
name: 'toolPreset',
|
|
153
|
+
type: 'options',
|
|
154
|
+
options: [
|
|
155
|
+
{ name: 'All Tools', value: 'default' },
|
|
156
|
+
{ name: 'Code Edit', value: 'Read,Edit,Write,Glob,Grep' },
|
|
157
|
+
{ name: 'Code Review', value: 'Read,Glob,Grep,WebSearch,WebFetch' },
|
|
158
|
+
{ name: 'Full Development', value: 'Read,Edit,Write,Bash,Glob,Grep' },
|
|
159
|
+
{ name: 'Read Only', value: 'Read,Glob,Grep' },
|
|
160
|
+
],
|
|
161
|
+
default: 'Read,Glob,Grep',
|
|
162
|
+
displayOptions: {
|
|
163
|
+
show: {
|
|
164
|
+
toolControl: ['preset'],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
description: 'Predefined tool combinations',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
displayName: 'Tools',
|
|
171
|
+
name: 'tools',
|
|
172
|
+
type: 'string',
|
|
173
|
+
default: 'Read,Edit,Bash',
|
|
174
|
+
displayOptions: {
|
|
175
|
+
show: {
|
|
176
|
+
toolControl: ['custom'],
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
description: 'Comma-separated list of tools to enable',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
displayName: 'Allowed Tools',
|
|
183
|
+
name: 'allowedTools',
|
|
184
|
+
type: 'string',
|
|
185
|
+
default: '',
|
|
186
|
+
displayOptions: {
|
|
187
|
+
show: {
|
|
188
|
+
toolControl: ['allow'],
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
description: 'Comma-separated patterns for allowed tools',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
displayName: 'Disallowed Tools',
|
|
195
|
+
name: 'disallowedTools',
|
|
196
|
+
type: 'string',
|
|
197
|
+
default: '',
|
|
198
|
+
displayOptions: {
|
|
199
|
+
show: {
|
|
200
|
+
toolControl: ['deny'],
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
description: 'Comma-separated patterns for disallowed tools',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
displayName: 'Max Turns',
|
|
207
|
+
name: 'maxTurns',
|
|
208
|
+
type: 'number',
|
|
209
|
+
default: 0,
|
|
210
|
+
description: 'Maximum agent turns (0 = unlimited)',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
displayName: 'Custom Agents',
|
|
214
|
+
name: 'customAgents',
|
|
215
|
+
type: 'json',
|
|
216
|
+
default: '',
|
|
217
|
+
description: 'Custom sub-agent definitions (JSON)',
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
displayName: 'MCP Config Path',
|
|
221
|
+
name: 'mcpConfigPath',
|
|
222
|
+
type: 'string',
|
|
223
|
+
default: '',
|
|
224
|
+
description: 'Path to MCP configuration file',
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
displayName: 'Permission Mode',
|
|
228
|
+
name: 'permissionMode',
|
|
229
|
+
type: 'options',
|
|
230
|
+
options: [
|
|
231
|
+
{ name: 'Default', value: '' },
|
|
232
|
+
{ name: 'Plan', value: 'plan' },
|
|
233
|
+
],
|
|
234
|
+
default: '',
|
|
235
|
+
description: 'Permission mode for Claude Code',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
displayName: 'Additional Options',
|
|
239
|
+
name: 'additionalOptions',
|
|
240
|
+
type: 'collection',
|
|
241
|
+
placeholder: 'Add Option',
|
|
242
|
+
default: {},
|
|
243
|
+
options: [
|
|
244
|
+
{
|
|
245
|
+
displayName: 'Additional Directories',
|
|
246
|
+
name: 'additionalDirs',
|
|
247
|
+
type: 'string',
|
|
248
|
+
default: '',
|
|
249
|
+
description: 'Comma-separated additional working directories',
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
displayName: 'Betas',
|
|
253
|
+
name: 'betas',
|
|
254
|
+
type: 'string',
|
|
255
|
+
default: '',
|
|
256
|
+
description: 'Comma-separated beta features to enable',
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
displayName: 'Debug',
|
|
260
|
+
name: 'debug',
|
|
261
|
+
type: 'string',
|
|
262
|
+
default: '',
|
|
263
|
+
description: 'Debug filter (e.g., api,mcp)',
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
displayName: 'Extra CLI Flags',
|
|
267
|
+
name: 'extraFlags',
|
|
268
|
+
type: 'string',
|
|
269
|
+
default: '',
|
|
270
|
+
description: 'Additional CLI flags (advanced)',
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
displayName: 'Fallback Model',
|
|
274
|
+
name: 'fallbackModel',
|
|
275
|
+
type: 'string',
|
|
276
|
+
default: '',
|
|
277
|
+
description: 'Fallback model to use if primary fails',
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
displayName: 'JSON Schema',
|
|
281
|
+
name: 'jsonSchema',
|
|
282
|
+
type: 'json',
|
|
283
|
+
default: '',
|
|
284
|
+
description: 'Output JSON schema for structured responses',
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
displayName: 'Skip Permissions',
|
|
288
|
+
name: 'skipPermissions',
|
|
289
|
+
type: 'boolean',
|
|
290
|
+
default: false,
|
|
291
|
+
description: 'Whether to skip permission checks (DANGEROUS)',
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
displayName: 'Timeout (Seconds)',
|
|
295
|
+
name: 'timeout',
|
|
296
|
+
type: 'number',
|
|
297
|
+
default: 300,
|
|
298
|
+
description: 'Execution timeout in seconds',
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
displayName: 'Verbose',
|
|
302
|
+
name: 'verbose',
|
|
303
|
+
type: 'boolean',
|
|
304
|
+
default: false,
|
|
305
|
+
description: 'Whether to enable verbose logging',
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
async execute() {
|
|
313
|
+
const items = this.getInputData();
|
|
314
|
+
const returnData = [];
|
|
315
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
316
|
+
try {
|
|
317
|
+
const prompt = this.getNodeParameter('prompt', itemIndex, '');
|
|
318
|
+
const workingDirectory = this.getNodeParameter('workingDirectory', itemIndex, '');
|
|
319
|
+
const model = this.getNodeParameter('model', itemIndex, '');
|
|
320
|
+
const customModel = this.getNodeParameter('customModel', itemIndex, '');
|
|
321
|
+
const systemPromptMode = this.getNodeParameter('systemPromptMode', itemIndex, 'none');
|
|
322
|
+
const systemPrompt = this.getNodeParameter('systemPrompt', itemIndex, '');
|
|
323
|
+
const sessionMode = this.getNodeParameter('sessionMode', itemIndex, 'new');
|
|
324
|
+
const sessionId = this.getNodeParameter('sessionId', itemIndex, '');
|
|
325
|
+
const forkSession = this.getNodeParameter('forkSession', itemIndex, false);
|
|
326
|
+
const toolControl = this.getNodeParameter('toolControl', itemIndex, 'default');
|
|
327
|
+
const toolPreset = this.getNodeParameter('toolPreset', itemIndex, '');
|
|
328
|
+
const tools = this.getNodeParameter('tools', itemIndex, '');
|
|
329
|
+
const allowedTools = this.getNodeParameter('allowedTools', itemIndex, '');
|
|
330
|
+
const disallowedTools = this.getNodeParameter('disallowedTools', itemIndex, '');
|
|
331
|
+
const maxTurns = this.getNodeParameter('maxTurns', itemIndex, 0);
|
|
332
|
+
const customAgents = this.getNodeParameter('customAgents', itemIndex, '');
|
|
333
|
+
const mcpConfigPath = this.getNodeParameter('mcpConfigPath', itemIndex, '');
|
|
334
|
+
const permissionMode = this.getNodeParameter('permissionMode', itemIndex, '');
|
|
335
|
+
const additionalOptions = this.getNodeParameter('additionalOptions', itemIndex, {});
|
|
336
|
+
const commandParams = {
|
|
337
|
+
prompt,
|
|
338
|
+
model,
|
|
339
|
+
customModel,
|
|
340
|
+
systemPromptMode,
|
|
341
|
+
systemPrompt,
|
|
342
|
+
sessionMode,
|
|
343
|
+
sessionId,
|
|
344
|
+
forkSession,
|
|
345
|
+
toolControl,
|
|
346
|
+
toolPreset,
|
|
347
|
+
tools,
|
|
348
|
+
allowedTools,
|
|
349
|
+
disallowedTools,
|
|
350
|
+
maxTurns,
|
|
351
|
+
customAgents,
|
|
352
|
+
mcpConfigPath,
|
|
353
|
+
permissionMode,
|
|
354
|
+
additionalOptions,
|
|
355
|
+
};
|
|
356
|
+
const { args, errors } = (0, commandBuilder_1.buildCommand)(commandParams);
|
|
357
|
+
if (errors.length > 0) {
|
|
358
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Parameter validation failed: ${errors.join(', ')}`);
|
|
359
|
+
}
|
|
360
|
+
const timeoutMs = (additionalOptions.timeout || 300) * 1000;
|
|
361
|
+
const processResult = await (0, processRunner_1.runProcess)(this.getNode(), args, {
|
|
362
|
+
cwd: workingDirectory || undefined,
|
|
363
|
+
timeout: timeoutMs,
|
|
364
|
+
});
|
|
365
|
+
const parsedOutput = (0, outputParser_1.parseOutput)(processResult.stdout);
|
|
366
|
+
returnData.push({
|
|
367
|
+
json: {
|
|
368
|
+
result: parsedOutput.result,
|
|
369
|
+
sessionId: parsedOutput.sessionId,
|
|
370
|
+
usage: parsedOutput.usage,
|
|
371
|
+
exitCode: processResult.exitCode,
|
|
372
|
+
raw: parsedOutput.raw,
|
|
373
|
+
...(parsedOutput.parseError && { parseError: parsedOutput.parseError }),
|
|
374
|
+
},
|
|
375
|
+
pairedItem: itemIndex,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
if (this.continueOnFail()) {
|
|
380
|
+
returnData.push({
|
|
381
|
+
json: {
|
|
382
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
383
|
+
},
|
|
384
|
+
pairedItem: itemIndex,
|
|
385
|
+
});
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
throw error;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return [returnData];
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
exports.ClaudeCode = ClaudeCode;
|
|
395
|
+
//# sourceMappingURL=ClaudeCode.node.js.map
|