n8n-nodes-claude-code-cli 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.
Files changed (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +603 -0
  3. package/dist/credentials/ClaudeCodeDockerApi.credentials.d.ts +9 -0
  4. package/dist/credentials/ClaudeCodeDockerApi.credentials.d.ts.map +1 -0
  5. package/dist/credentials/ClaudeCodeDockerApi.credentials.js +82 -0
  6. package/dist/credentials/ClaudeCodeDockerApi.credentials.js.map +1 -0
  7. package/dist/credentials/ClaudeCodeLocalApi.credentials.d.ts +9 -0
  8. package/dist/credentials/ClaudeCodeLocalApi.credentials.d.ts.map +1 -0
  9. package/dist/credentials/ClaudeCodeLocalApi.credentials.js +35 -0
  10. package/dist/credentials/ClaudeCodeLocalApi.credentials.js.map +1 -0
  11. package/dist/credentials/ClaudeCodeSshApi.credentials.d.ts +9 -0
  12. package/dist/credentials/ClaudeCodeSshApi.credentials.d.ts.map +1 -0
  13. package/dist/credentials/ClaudeCodeSshApi.credentials.js +119 -0
  14. package/dist/credentials/ClaudeCodeSshApi.credentials.js.map +1 -0
  15. package/dist/icons/claudecode.svg +40 -0
  16. package/dist/index.d.ts +5 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +21 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/nodes/ClaudeCode/ClaudeCode.node.d.ts +6 -0
  21. package/dist/nodes/ClaudeCode/ClaudeCode.node.d.ts.map +1 -0
  22. package/dist/nodes/ClaudeCode/ClaudeCode.node.js +131 -0
  23. package/dist/nodes/ClaudeCode/ClaudeCode.node.js.map +1 -0
  24. package/dist/nodes/ClaudeCode/descriptions/connectionModeDescription.d.ts +3 -0
  25. package/dist/nodes/ClaudeCode/descriptions/connectionModeDescription.d.ts.map +1 -0
  26. package/dist/nodes/ClaudeCode/descriptions/connectionModeDescription.js +30 -0
  27. package/dist/nodes/ClaudeCode/descriptions/connectionModeDescription.js.map +1 -0
  28. package/dist/nodes/ClaudeCode/descriptions/contextDescription.d.ts +3 -0
  29. package/dist/nodes/ClaudeCode/descriptions/contextDescription.d.ts.map +1 -0
  30. package/dist/nodes/ClaudeCode/descriptions/contextDescription.js +52 -0
  31. package/dist/nodes/ClaudeCode/descriptions/contextDescription.js.map +1 -0
  32. package/dist/nodes/ClaudeCode/descriptions/index.d.ts +9 -0
  33. package/dist/nodes/ClaudeCode/descriptions/index.d.ts.map +1 -0
  34. package/dist/nodes/ClaudeCode/descriptions/index.js +20 -0
  35. package/dist/nodes/ClaudeCode/descriptions/index.js.map +1 -0
  36. package/dist/nodes/ClaudeCode/descriptions/modelDescription.d.ts +3 -0
  37. package/dist/nodes/ClaudeCode/descriptions/modelDescription.d.ts.map +1 -0
  38. package/dist/nodes/ClaudeCode/descriptions/modelDescription.js +49 -0
  39. package/dist/nodes/ClaudeCode/descriptions/modelDescription.js.map +1 -0
  40. package/dist/nodes/ClaudeCode/descriptions/operationDescription.d.ts +3 -0
  41. package/dist/nodes/ClaudeCode/descriptions/operationDescription.d.ts.map +1 -0
  42. package/dist/nodes/ClaudeCode/descriptions/operationDescription.js +39 -0
  43. package/dist/nodes/ClaudeCode/descriptions/operationDescription.js.map +1 -0
  44. package/dist/nodes/ClaudeCode/descriptions/optionsDescription.d.ts +3 -0
  45. package/dist/nodes/ClaudeCode/descriptions/optionsDescription.d.ts.map +1 -0
  46. package/dist/nodes/ClaudeCode/descriptions/optionsDescription.js +67 -0
  47. package/dist/nodes/ClaudeCode/descriptions/optionsDescription.js.map +1 -0
  48. package/dist/nodes/ClaudeCode/descriptions/promptDescription.d.ts +3 -0
  49. package/dist/nodes/ClaudeCode/descriptions/promptDescription.d.ts.map +1 -0
  50. package/dist/nodes/ClaudeCode/descriptions/promptDescription.js +28 -0
  51. package/dist/nodes/ClaudeCode/descriptions/promptDescription.js.map +1 -0
  52. package/dist/nodes/ClaudeCode/descriptions/sessionDescription.d.ts +3 -0
  53. package/dist/nodes/ClaudeCode/descriptions/sessionDescription.d.ts.map +1 -0
  54. package/dist/nodes/ClaudeCode/descriptions/sessionDescription.js +20 -0
  55. package/dist/nodes/ClaudeCode/descriptions/sessionDescription.js.map +1 -0
  56. package/dist/nodes/ClaudeCode/descriptions/toolPermissionsDescription.d.ts +3 -0
  57. package/dist/nodes/ClaudeCode/descriptions/toolPermissionsDescription.d.ts.map +1 -0
  58. package/dist/nodes/ClaudeCode/descriptions/toolPermissionsDescription.js +31 -0
  59. package/dist/nodes/ClaudeCode/descriptions/toolPermissionsDescription.js.map +1 -0
  60. package/dist/nodes/ClaudeCode/interfaces/ClaudeCodeTypes.d.ts +143 -0
  61. package/dist/nodes/ClaudeCode/interfaces/ClaudeCodeTypes.d.ts.map +1 -0
  62. package/dist/nodes/ClaudeCode/interfaces/ClaudeCodeTypes.js +3 -0
  63. package/dist/nodes/ClaudeCode/interfaces/ClaudeCodeTypes.js.map +1 -0
  64. package/dist/nodes/ClaudeCode/interfaces/index.d.ts +2 -0
  65. package/dist/nodes/ClaudeCode/interfaces/index.d.ts.map +1 -0
  66. package/dist/nodes/ClaudeCode/interfaces/index.js +3 -0
  67. package/dist/nodes/ClaudeCode/interfaces/index.js.map +1 -0
  68. package/dist/nodes/ClaudeCode/transport/DockerExecutor.d.ts +29 -0
  69. package/dist/nodes/ClaudeCode/transport/DockerExecutor.d.ts.map +1 -0
  70. package/dist/nodes/ClaudeCode/transport/DockerExecutor.js +153 -0
  71. package/dist/nodes/ClaudeCode/transport/DockerExecutor.js.map +1 -0
  72. package/dist/nodes/ClaudeCode/transport/ExecutorFactory.d.ts +6 -0
  73. package/dist/nodes/ClaudeCode/transport/ExecutorFactory.d.ts.map +1 -0
  74. package/dist/nodes/ClaudeCode/transport/ExecutorFactory.js +22 -0
  75. package/dist/nodes/ClaudeCode/transport/ExecutorFactory.js.map +1 -0
  76. package/dist/nodes/ClaudeCode/transport/LocalExecutor.d.ts +18 -0
  77. package/dist/nodes/ClaudeCode/transport/LocalExecutor.d.ts.map +1 -0
  78. package/dist/nodes/ClaudeCode/transport/LocalExecutor.js +83 -0
  79. package/dist/nodes/ClaudeCode/transport/LocalExecutor.js.map +1 -0
  80. package/dist/nodes/ClaudeCode/transport/SshExecutor.d.ts +25 -0
  81. package/dist/nodes/ClaudeCode/transport/SshExecutor.d.ts.map +1 -0
  82. package/dist/nodes/ClaudeCode/transport/SshExecutor.js +174 -0
  83. package/dist/nodes/ClaudeCode/transport/SshExecutor.js.map +1 -0
  84. package/dist/nodes/ClaudeCode/transport/index.d.ts +5 -0
  85. package/dist/nodes/ClaudeCode/transport/index.d.ts.map +1 -0
  86. package/dist/nodes/ClaudeCode/transport/index.js +12 -0
  87. package/dist/nodes/ClaudeCode/transport/index.js.map +1 -0
  88. package/dist/nodes/ClaudeCode/utils/commandBuilder.d.ts +16 -0
  89. package/dist/nodes/ClaudeCode/utils/commandBuilder.d.ts.map +1 -0
  90. package/dist/nodes/ClaudeCode/utils/commandBuilder.js +100 -0
  91. package/dist/nodes/ClaudeCode/utils/commandBuilder.js.map +1 -0
  92. package/dist/nodes/ClaudeCode/utils/index.d.ts +4 -0
  93. package/dist/nodes/ClaudeCode/utils/index.d.ts.map +1 -0
  94. package/dist/nodes/ClaudeCode/utils/index.js +14 -0
  95. package/dist/nodes/ClaudeCode/utils/index.js.map +1 -0
  96. package/dist/nodes/ClaudeCode/utils/optionsBuilder.d.ts +7 -0
  97. package/dist/nodes/ClaudeCode/utils/optionsBuilder.d.ts.map +1 -0
  98. package/dist/nodes/ClaudeCode/utils/optionsBuilder.js +84 -0
  99. package/dist/nodes/ClaudeCode/utils/optionsBuilder.js.map +1 -0
  100. package/dist/nodes/ClaudeCode/utils/outputParser.d.ts +14 -0
  101. package/dist/nodes/ClaudeCode/utils/outputParser.d.ts.map +1 -0
  102. package/dist/nodes/ClaudeCode/utils/outputParser.js +80 -0
  103. package/dist/nodes/ClaudeCode/utils/outputParser.js.map +1 -0
  104. package/package.json +75 -0
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCommand = buildCommand;
4
+ exports.escapeShellArg = escapeShellArg;
5
+ exports.buildShellCommand = buildShellCommand;
6
+ /**
7
+ * Builds the Claude Code CLI command parts from execution options
8
+ */
9
+ function buildCommand(options, credentials) {
10
+ const args = [];
11
+ const env = {};
12
+ // Print mode flag (headless/non-interactive)
13
+ args.push("-p");
14
+ args.push(options.prompt);
15
+ // Output format
16
+ if (options.outputFormat) {
17
+ args.push("--output-format", options.outputFormat);
18
+ }
19
+ // Model selection
20
+ if (options.model) {
21
+ args.push("--model", options.model);
22
+ }
23
+ // Max turns
24
+ if (options.maxTurns && options.maxTurns > 0) {
25
+ args.push("--max-turns", String(options.maxTurns));
26
+ }
27
+ // Session management
28
+ if (options.session?.continueLastSession) {
29
+ args.push("--continue");
30
+ }
31
+ else if (options.session?.sessionId) {
32
+ args.push("--resume", options.session.sessionId);
33
+ }
34
+ // Tool permissions
35
+ if (options.toolPermissions?.allowedTools &&
36
+ options.toolPermissions.allowedTools.length > 0) {
37
+ args.push("--allowedTools", options.toolPermissions.allowedTools.join(","));
38
+ }
39
+ if (options.toolPermissions?.disallowedTools &&
40
+ options.toolPermissions.disallowedTools.length > 0) {
41
+ args.push("--disallowedTools", options.toolPermissions.disallowedTools.join(","));
42
+ }
43
+ // System prompt append
44
+ if (options.systemPrompt) {
45
+ args.push("--append-system-prompt", options.systemPrompt);
46
+ }
47
+ // Context files (via --add-dir for directories containing the files)
48
+ if (options.contextFiles && options.contextFiles.length > 0) {
49
+ const uniqueDirs = new Set();
50
+ options.contextFiles.forEach((file) => {
51
+ const lastSlash = file.path.lastIndexOf("/");
52
+ if (lastSlash > 0) {
53
+ uniqueDirs.add(file.path.substring(0, lastSlash));
54
+ }
55
+ });
56
+ uniqueDirs.forEach((dir) => {
57
+ args.push("--add-dir", dir);
58
+ });
59
+ }
60
+ // Additional arguments
61
+ if (options.additionalArgs && options.additionalArgs.length > 0) {
62
+ args.push(...options.additionalArgs);
63
+ }
64
+ // Parse env vars from local credentials
65
+ if ("envVars" in credentials && credentials.envVars) {
66
+ const envVarsString = credentials.envVars;
67
+ if (envVarsString && envVarsString !== "{}") {
68
+ const parsed = JSON.parse(envVarsString);
69
+ Object.assign(env, parsed);
70
+ }
71
+ }
72
+ const claudePath = credentials.claudePath || "claude";
73
+ const cwd = options.workingDirectory || credentials.defaultWorkingDir || undefined;
74
+ return {
75
+ command: claudePath,
76
+ args,
77
+ env: Object.keys(env).length > 0 ? env : undefined,
78
+ cwd,
79
+ };
80
+ }
81
+ /**
82
+ * Escapes a shell argument for safe use in SSH/Docker exec commands
83
+ */
84
+ function escapeShellArg(arg) {
85
+ // Single-quote the argument and escape any existing single quotes
86
+ return `'${arg.replace(/'/g, "'\\''")}'`;
87
+ }
88
+ /**
89
+ * Builds a complete shell command string from parts
90
+ */
91
+ function buildShellCommand(parts) {
92
+ const escapedArgs = parts.args.map(escapeShellArg);
93
+ let cmd = "";
94
+ if (parts.cwd) {
95
+ cmd += `cd ${escapeShellArg(parts.cwd)} && `;
96
+ }
97
+ cmd += `${parts.command} ${escapedArgs.join(" ")}`;
98
+ return cmd;
99
+ }
100
+ //# sourceMappingURL=commandBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandBuilder.js","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/commandBuilder.ts"],"names":[],"mappings":";;AAaA,oCA6FC;AAKD,wCAGC;AAKD,8CAWC;AAxHD;;GAEG;AACH,SAAgB,YAAY,CAC3B,OAAmC,EACnC,WAA2B;IAE3B,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,GAAG,GAA2B,EAAE,CAAC;IAEvC,6CAA6C;IAC7C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1B,gBAAgB;IAChB,IAAI,OAAO,CAAC,YAA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AAM,CAAC,CAAC;QAC5B,CAAC;IACF,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,IAAI,QAAQ,CAAC;IACtD,MAAM,GAAG,GACR,OAAO,CAAC,gBAAgB,IAAI,WAAW,CAAC,iBAAiB,IAAI,SAAS,CAAC;IAExE,OAAO;QACN,OAAO,EAAE,UAAU;QACnB,IAAI;QACJ,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;QAClD,GAAG;KACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,GAAW;IACzC,kEAAkE;IAClE,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAAmB;IACpD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACnD,IAAI,GAAG,GAAG,EAAE,CAAC;IAEb,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;QACf,GAAG,IAAI,MAAM,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;IAC9C,CAAC;IAED,GAAG,IAAI,GAAG,KAAK,CAAC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IAEnD,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { buildCommand, escapeShellArg, buildShellCommand, } from "./commandBuilder.js";
2
+ export { parseJsonOutput, normalizeOutput, createErrorResult, } from "./outputParser.js";
3
+ export { buildExecutionOptions } from "./optionsBuilder.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,cAAc,EACd,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,eAAe,EACf,eAAe,EACf,iBAAiB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildExecutionOptions = exports.createErrorResult = exports.normalizeOutput = exports.parseJsonOutput = exports.buildShellCommand = exports.escapeShellArg = exports.buildCommand = void 0;
4
+ var commandBuilder_js_1 = require("./commandBuilder.js");
5
+ Object.defineProperty(exports, "buildCommand", { enumerable: true, get: function () { return commandBuilder_js_1.buildCommand; } });
6
+ Object.defineProperty(exports, "escapeShellArg", { enumerable: true, get: function () { return commandBuilder_js_1.escapeShellArg; } });
7
+ Object.defineProperty(exports, "buildShellCommand", { enumerable: true, get: function () { return commandBuilder_js_1.buildShellCommand; } });
8
+ var outputParser_js_1 = require("./outputParser.js");
9
+ Object.defineProperty(exports, "parseJsonOutput", { enumerable: true, get: function () { return outputParser_js_1.parseJsonOutput; } });
10
+ Object.defineProperty(exports, "normalizeOutput", { enumerable: true, get: function () { return outputParser_js_1.normalizeOutput; } });
11
+ Object.defineProperty(exports, "createErrorResult", { enumerable: true, get: function () { return outputParser_js_1.createErrorResult; } });
12
+ var optionsBuilder_js_1 = require("./optionsBuilder.js");
13
+ Object.defineProperty(exports, "buildExecutionOptions", { enumerable: true, get: function () { return optionsBuilder_js_1.buildExecutionOptions; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/index.ts"],"names":[],"mappings":";;;AAAA,yDAI6B;AAH5B,iHAAA,YAAY,OAAA;AACZ,mHAAA,cAAc,OAAA;AACd,sHAAA,iBAAiB,OAAA;AAElB,qDAI2B;AAH1B,kHAAA,eAAe,OAAA;AACf,kHAAA,eAAe,OAAA;AACf,oHAAA,iBAAiB,OAAA;AAElB,yDAA4D;AAAnD,0HAAA,qBAAqB,OAAA"}
@@ -0,0 +1,7 @@
1
+ import type { IExecuteFunctions } from "n8n-workflow";
2
+ import type { ClaudeCodeExecutionOptions, ClaudeCodeOperation } from "../interfaces/index.js";
3
+ /**
4
+ * Builds execution options from n8n node parameters
5
+ */
6
+ export declare function buildExecutionOptions(context: IExecuteFunctions, itemIndex: number, operation: ClaudeCodeOperation): ClaudeCodeExecutionOptions;
7
+ //# sourceMappingURL=optionsBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optionsBuilder.d.ts","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/optionsBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EACX,0BAA0B,EAC1B,mBAAmB,EAKnB,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,mBAAmB,GAC5B,0BAA0B,CAoG5B"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildExecutionOptions = buildExecutionOptions;
4
+ /**
5
+ * Builds execution options from n8n node parameters
6
+ */
7
+ function buildExecutionOptions(context, itemIndex, operation) {
8
+ const prompt = context.getNodeParameter("prompt", itemIndex, "");
9
+ const options = context.getNodeParameter("options", itemIndex, {});
10
+ // Parse tool permissions
11
+ const toolPermsRaw = context.getNodeParameter("toolPermissions", itemIndex, {});
12
+ const toolPermissions = {
13
+ allowedTools: toolPermsRaw.allowedTools
14
+ ? toolPermsRaw.allowedTools
15
+ .split(",")
16
+ .map((t) => t.trim())
17
+ .filter(Boolean)
18
+ : undefined,
19
+ disallowedTools: toolPermsRaw.disallowedTools
20
+ ? toolPermsRaw.disallowedTools
21
+ .split(",")
22
+ .map((t) => t.trim())
23
+ .filter(Boolean)
24
+ : undefined,
25
+ };
26
+ // Parse additional args
27
+ const additionalArgsStr = options.additionalArgs || "";
28
+ const additionalArgs = additionalArgsStr.split(" ").filter(Boolean);
29
+ // Build session config based on operation
30
+ let session;
31
+ if (operation === "continueSession") {
32
+ session = { continueLastSession: true };
33
+ }
34
+ else if (operation === "resumeSession") {
35
+ const sessionId = context.getNodeParameter("sessionId", itemIndex, "");
36
+ session = { sessionId };
37
+ }
38
+ // Parse context files for executeWithContext operation
39
+ let contextFiles;
40
+ if (operation === "executeWithContext") {
41
+ const filesData = context.getNodeParameter("contextFiles", itemIndex, {
42
+ files: [],
43
+ });
44
+ contextFiles = filesData.files?.map((f) => ({ path: f.path })) || [];
45
+ // Also add additional directories
46
+ const additionalDirs = context.getNodeParameter("additionalDirs", itemIndex, "");
47
+ if (additionalDirs) {
48
+ const dirs = additionalDirs
49
+ .split(",")
50
+ .map((d) => d.trim())
51
+ .filter(Boolean);
52
+ dirs.forEach((dir) => {
53
+ contextFiles?.push({ path: dir });
54
+ });
55
+ }
56
+ }
57
+ // Determine output format
58
+ let outputFormat = "json";
59
+ if (options.outputFormat) {
60
+ outputFormat = options.outputFormat;
61
+ }
62
+ // Handle model selection (now at root level, not in options)
63
+ let model = context.getNodeParameter("model", itemIndex, "");
64
+ if (model === "custom") {
65
+ model = context.getNodeParameter("customModel", itemIndex, "");
66
+ }
67
+ if (!model) {
68
+ model = undefined;
69
+ }
70
+ return {
71
+ prompt,
72
+ workingDirectory: options.workingDirectory,
73
+ outputFormat,
74
+ model,
75
+ maxTurns: options.maxTurns || undefined,
76
+ toolPermissions,
77
+ session,
78
+ contextFiles,
79
+ additionalArgs: additionalArgs.length > 0 ? additionalArgs : undefined,
80
+ timeout: options.timeout || 300,
81
+ systemPrompt: options.systemPrompt || undefined,
82
+ };
83
+ }
84
+ //# sourceMappingURL=optionsBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optionsBuilder.js","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/optionsBuilder.ts"],"names":[],"mappings":";;AAaA,sDAwGC;AA3GD;;GAEG;AACH,SAAgB,qBAAqB,CACpC,OAA0B,EAC1B,SAAiB,EACjB,SAA8B;IAE9B,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,CAAW,CAAC;IAC3E,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAGhE,CAAC;IAEF,yBAAyB;IACzB,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAC5C,iBAAiB,EACjB,SAAS,EACT,EAAE,CACwB,CAAC;IAC5B,MAAM,eAAe,GAAoB;QACxC,YAAY,EAAE,YAAY,CAAC,YAAY;YACtC,CAAC,CAAC,YAAY,CAAC,YAAY;iBACxB,KAAK,CAAC,GAAG,CAAC;iBACV,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;iBAC5B,MAAM,CAAC,OAAO,CAAC;YAClB,CAAC,CAAC,SAAS;QACZ,eAAe,EAAE,YAAY,CAAC,eAAe;YAC5C,CAAC,CAAC,YAAY,CAAC,eAAe;iBAC3B,KAAK,CAAC,GAAG,CAAC;iBACV,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;iBAC5B,MAAM,CAAC,OAAO,CAAC;YAClB,CAAC,CAAC,SAAS;KACZ,CAAC;IAEF,wBAAwB;IACxB,MAAM,iBAAiB,GAAI,OAAO,CAAC,cAAyB,IAAI,EAAE,CAAC;IACnE,MAAM,cAAc,GAAG,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEpE,0CA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AC;IACxC,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QAC1B,YAAY,GAAG,OAAO,CAAC,YAA4B,CAAC;IACrD,CAAC;IAED,6DAA6D;IAC7D,IAAI,KAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CAAW,CAAC;IACvE,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxB,KAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,SAAS,EAAE,EAAE,CAAW,CAAC;IAC1E,CAAC;IACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,KAAK,GAAG,SAA8B,CAAC;IACxC,CAAC;IAED,OAAO;QACN,MAAM;QACN,gBAAgB,EAAE,OAAO,CAAC,gBAAsC;QAChE,YAAY;QACZ,KAAK;QACL,QAAQ,EAAG,OAAO,CAAC,QAAmB,IAAI,SAAS;QACnD,eAAe;QACf,OAAO;QACP,YAAY;QACZ,cAAc,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;QACtE,OAAO,EAAG,OAAO,CAAC,OAAkB,IAAI,GAAG;QAC3C,YAAY,EAAG,OAAO,CAAC,YAAuB,IAAI,SAAS;KAC3D,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ClaudeCodeJsonOutput, ClaudeCodeResult } from "../interfaces/index.js";
2
+ /**
3
+ * Parses JSON output from Claude Code CLI
4
+ */
5
+ export declare function parseJsonOutput(output: string): ClaudeCodeJsonOutput;
6
+ /**
7
+ * Converts raw Claude Code JSON output to normalized result
8
+ */
9
+ export declare function normalizeOutput(jsonOutput: ClaudeCodeJsonOutput, exitCode: number, duration: number, stderr?: string): ClaudeCodeResult;
10
+ /**
11
+ * Creates an error result
12
+ */
13
+ export declare function createErrorResult(error: string, exitCode: number, duration: number): ClaudeCodeResult;
14
+ //# sourceMappingURL=outputParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputParser.d.ts","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/outputParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,oBAAoB,EACpB,gBAAgB,EAChB,MAAM,wBAAwB,CAAC;AAahC;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CA8BpE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC9B,UAAU,EAAE,oBAAoB,EAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GACb,gBAAgB,CAoBlB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACd,gBAAgB,CASlB"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseJsonOutput = parseJsonOutput;
4
+ exports.normalizeOutput = normalizeOutput;
5
+ exports.createErrorResult = createErrorResult;
6
+ /**
7
+ * Creates a default empty JSON output structure
8
+ */
9
+ function createDefaultOutput() {
10
+ return {
11
+ session_id: "",
12
+ result: undefined,
13
+ is_error: false,
14
+ };
15
+ }
16
+ /**
17
+ * Parses JSON output from Claude Code CLI
18
+ */
19
+ function parseJsonOutput(output) {
20
+ if (!output.trim()) {
21
+ return createDefaultOutput();
22
+ }
23
+ const trimmedOutput = output.trim();
24
+ // If it starts with {, try to parse as single JSON object
25
+ if (trimmedOutput.startsWith("{")) {
26
+ // Find the last complete JSON object (in case of multiple lines)
27
+ const lines = trimmedOutput.split("\n");
28
+ let lastValidJson = null;
29
+ for (const line of lines) {
30
+ const trimmedLine = line.trim();
31
+ if (trimmedLine.startsWith("{")) {
32
+ const parsed = JSON.parse(trimmedLine);
33
+ lastValidJson = parsed;
34
+ }
35
+ }
36
+ if (lastValidJson) {
37
+ return lastValidJson;
38
+ }
39
+ // Fallback: try parsing the entire output as single JSON
40
+ return JSON.parse(trimmedOutput);
41
+ }
42
+ return createDefaultOutput();
43
+ }
44
+ /**
45
+ * Converts raw Claude Code JSON output to normalized result
46
+ */
47
+ function normalizeOutput(jsonOutput, exitCode, duration, stderr) {
48
+ const success = exitCode === 0 && !jsonOutput.is_error;
49
+ return {
50
+ success,
51
+ sessionId: jsonOutput.session_id || "",
52
+ output: jsonOutput.result || "",
53
+ rawOutput: jsonOutput,
54
+ exitCode,
55
+ duration,
56
+ cost: jsonOutput.total_cost_usd,
57
+ numTurns: jsonOutput.num_turns,
58
+ usage: jsonOutput.usage
59
+ ? {
60
+ inputTokens: jsonOutput.usage.input_tokens,
61
+ outputTokens: jsonOutput.usage.output_tokens,
62
+ }
63
+ : undefined,
64
+ error: !success ? stderr || jsonOutput.result : undefined,
65
+ };
66
+ }
67
+ /**
68
+ * Creates an error result
69
+ */
70
+ function createErrorResult(error, exitCode, duration) {
71
+ return {
72
+ success: false,
73
+ sessionId: "",
74
+ output: "",
75
+ exitCode,
76
+ duration,
77
+ error,
78
+ };
79
+ }
80
+ //# sourceMappingURL=outputParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputParser.js","sourceRoot":"","sources":["../../../../nodes/ClaudeCode/utils/outputParser.ts"],"names":[],"mappings":";;AAmBA,0CA8BC;AAKD,0CAyBC;AAKD,8CAaC;AA5FD;;GAEG;AACH,SAAS,mBAAmB;IAC3B,OAAO;QACN,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,KAAK;KACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,MAAc;IAC7C,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QACpB,OAAO,mBAAmB,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAEpC,0DAA0D;IAC1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,CAAC,SAAS;QACZ,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;KACzD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAChC,KAAa,EACb,QAAgB,EAChB,QAAgB;IAEhB,OAAO;QACN,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,EAAE;QACb,MAAM,EAAE,EAAE;QACV,QAAQ;QACR,QAAQ;QACR,KAAK;KACL,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "n8n-nodes-claude-code-cli",
3
+ "version": "1.0.0",
4
+ "description": "n8n community node for Claude Code CLI integration - execute AI-assisted coding tasks",
5
+ "keywords": [
6
+ "n8n-community-node-package",
7
+ "claude",
8
+ "claude-code",
9
+ "ai",
10
+ "automation",
11
+ "anthropic",
12
+ "coding",
13
+ "development"
14
+ ],
15
+ "license": "MIT",
16
+ "homepage": "https://github.com/ThomasTartrau/n8n-nodes-claude-code-cli",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/ThomasTartrau/n8n-nodes-claude-code-cli.git"
20
+ },
21
+ "main": "dist/index.js",
22
+ "scripts": {
23
+ "build": "tsc && npm run copy:icons",
24
+ "copy:icons": "cp -r icons dist/",
25
+ "dev": "tsc --watch",
26
+ "lint": "biome check .",
27
+ "format": "biome format --write .",
28
+ "check": "biome format .",
29
+ "typecheck": "tsc --noEmit",
30
+ "test": "vitest run tests/utils",
31
+ "test:watch": "vitest",
32
+ "test:coverage": "vitest run --coverage",
33
+ "test:integration": "vitest run tests/integration",
34
+ "test:all": "vitest run",
35
+ "prepublishOnly": "npm run build"
36
+ },
37
+ "files": [
38
+ "dist"
39
+ ],
40
+ "n8n": {
41
+ "n8nNodesApiVersion": 1,
42
+ "credentials": [
43
+ "dist/credentials/ClaudeCodeLocalApi.credentials.js",
44
+ "dist/credentials/ClaudeCodeSshApi.credentials.js",
45
+ "dist/credentials/ClaudeCodeDockerApi.credentials.js"
46
+ ],
47
+ "nodes": [
48
+ "dist/nodes/ClaudeCode/ClaudeCode.node.js"
49
+ ]
50
+ },
51
+ "devDependencies": {
52
+ "@biomejs/biome": "^2.3.10",
53
+ "@semantic-release/changelog": "^6.0.3",
54
+ "@semantic-release/git": "^10.0.1",
55
+ "@types/node": "^25.0.3",
56
+ "@types/ssh2": "^1.15.5",
57
+ "@vitest/coverage-v8": "^4.0.16",
58
+ "semantic-release": "^25.0.2",
59
+ "testcontainers": "^11.11.0",
60
+ "typescript": "^5.9.3",
61
+ "vitest": "^4.0.16"
62
+ },
63
+ "dependencies": {
64
+ "ssh2": "^1.17.0"
65
+ },
66
+ "peerDependencies": {
67
+ "n8n-workflow": "*"
68
+ },
69
+ "engines": {
70
+ "node": ">=18.0.0"
71
+ },
72
+ "overrides": {
73
+ "form-data": "^4.0.4"
74
+ }
75
+ }