n8n-nodes-claude-code-cli 1.7.0 → 1.8.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/dist/index.js CHANGED
@@ -174310,6 +174310,18 @@ var optionsDescription = [
174310
174310
  default: "json",
174311
174311
  description: "Output format for Claude Code response. Stream JSON captures all tool interactions as streaming events."
174312
174312
  },
174313
+ {
174314
+ displayName: "Reasoning Effort",
174315
+ name: "effort",
174316
+ type: "options",
174317
+ options: [
174318
+ { name: "Low", value: "low" },
174319
+ { name: "Medium", value: "medium" },
174320
+ { name: "High", value: "high" }
174321
+ ],
174322
+ default: "high",
174323
+ description: "Controls the reasoning effort level. Low = fast and cheap, High = deep thinking. Useful for workflows where some tasks are simple (summary, extraction) vs complex (refactoring)."
174324
+ },
174313
174325
  {
174314
174326
  displayName: "Max Turns",
174315
174327
  name: "maxTurns",
@@ -174324,6 +174336,25 @@ var optionsDescription = [
174324
174336
  default: 300,
174325
174337
  description: "Execution timeout in seconds. Maximum: 3600 (1 hour)."
174326
174338
  },
174339
+ {
174340
+ displayName: "System Prompt Mode",
174341
+ name: "systemPromptMode",
174342
+ type: "options",
174343
+ options: [
174344
+ {
174345
+ name: "Append",
174346
+ value: "append",
174347
+ description: "Append to Claude Code default system prompt"
174348
+ },
174349
+ {
174350
+ name: "Replace",
174351
+ value: "replace",
174352
+ description: "Replace the entire Claude Code default system prompt"
174353
+ }
174354
+ ],
174355
+ default: "append",
174356
+ description: "Whether to append to or replace the default Claude Code system prompt. Replace gives full control over system instructions."
174357
+ },
174327
174358
  {
174328
174359
  displayName: "System Prompt",
174329
174360
  name: "systemPrompt",
@@ -174333,7 +174364,7 @@ var optionsDescription = [
174333
174364
  },
174334
174365
  default: "",
174335
174366
  placeholder: "You are a helpful code reviewer...",
174336
- description: "Additional system prompt to append to Claude Code default system prompt"
174367
+ description: "System prompt text. Behavior depends on System Prompt Mode: Append adds to the default prompt, Replace overrides it entirely."
174337
174368
  },
174338
174369
  {
174339
174370
  displayName: "System Prompt File",
@@ -174341,7 +174372,7 @@ var optionsDescription = [
174341
174372
  type: "string",
174342
174373
  default: "",
174343
174374
  placeholder: "/path/to/system-prompt.txt",
174344
- description: "Path to a file containing additional system prompt text to append to Claude Code default system prompt. Use this instead of inline System Prompt for long or reusable prompts."
174375
+ description: "Path to a file containing system prompt text. Behavior depends on System Prompt Mode: Append adds to the default prompt, Replace overrides it entirely."
174345
174376
  },
174346
174377
  {
174347
174378
  displayName: "Verbose",
@@ -174357,6 +174388,13 @@ var optionsDescription = [
174357
174388
  default: 0,
174358
174389
  description: "Maximum dollar amount to spend before stopping execution. 0 means unlimited. Critical for controlling costs in automated workflows."
174359
174390
  },
174391
+ {
174392
+ displayName: "Max Output Tokens",
174393
+ name: "maxOutputTokens",
174394
+ type: "number",
174395
+ default: 0,
174396
+ description: "Maximum number of tokens in the output. 0 means unlimited. Useful for controlling costs and avoiding overly long responses in automated workflows. Sets CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable."
174397
+ },
174360
174398
  {
174361
174399
  displayName: "JSON Schema",
174362
174400
  name: "jsonSchema",
@@ -174454,14 +174492,25 @@ function buildCommand(options, credentials) {
174454
174492
  );
174455
174493
  }
174456
174494
  if (options.systemPrompt) {
174457
- args.push("--append-system-prompt", options.systemPrompt);
174495
+ if (options.systemPromptMode === "replace") {
174496
+ args.push("--system-prompt", options.systemPrompt);
174497
+ } else {
174498
+ args.push("--append-system-prompt", options.systemPrompt);
174499
+ }
174458
174500
  }
174459
174501
  if (options.systemPromptFile) {
174460
- args.push("--append-system-prompt-file", options.systemPromptFile);
174502
+ if (options.systemPromptMode === "replace") {
174503
+ args.push("--system-prompt-file", options.systemPromptFile);
174504
+ } else {
174505
+ args.push("--append-system-prompt-file", options.systemPromptFile);
174506
+ }
174461
174507
  }
174462
174508
  if (options.verbose && options.outputFormat !== "stream-json") {
174463
174509
  args.push("--verbose");
174464
174510
  }
174511
+ if (options.effort && options.effort !== "high") {
174512
+ args.push("--effort", options.effort);
174513
+ }
174465
174514
  if (options.maxBudgetUsd && options.maxBudgetUsd > 0) {
174466
174515
  args.push("--max-budget-usd", String(options.maxBudgetUsd));
174467
174516
  }
@@ -174515,6 +174564,9 @@ function buildCommand(options, credentials) {
174515
174564
  if (options.extendedContext === false) {
174516
174565
  env.CLAUDE_CODE_DISABLE_1M_CONTEXT = "1";
174517
174566
  }
174567
+ if (options.maxOutputTokens && options.maxOutputTokens > 0) {
174568
+ env.CLAUDE_CODE_MAX_OUTPUT_TOKENS = String(options.maxOutputTokens);
174569
+ }
174518
174570
  if ("envVars" in credentials && credentials.envVars) {
174519
174571
  const envVarsString = credentials.envVars;
174520
174572
  if (envVarsString && envVarsString !== "{}") {
@@ -174818,6 +174870,7 @@ function buildExecutionOptions(context, itemIndex, operation) {
174818
174870
  timeout: options.timeout || 300,
174819
174871
  systemPrompt: options.systemPrompt || void 0,
174820
174872
  systemPromptFile: options.systemPromptFile || void 0,
174873
+ systemPromptMode: options.systemPromptMode || void 0,
174821
174874
  verbose: options.verbose || void 0,
174822
174875
  maxBudgetUsd: options.maxBudgetUsd || void 0,
174823
174876
  jsonSchema: options.jsonSchema || void 0,
@@ -174825,7 +174878,9 @@ function buildExecutionOptions(context, itemIndex, operation) {
174825
174878
  agents,
174826
174879
  mcpConfig,
174827
174880
  extendedContext: options.extendedContext !== false,
174828
- worktree: options.worktreeEnabled ? options.worktreeName || "" : void 0
174881
+ worktree: options.worktreeEnabled ? options.worktreeName || "" : void 0,
174882
+ effort: options.effort && options.effort !== "high" ? options.effort : void 0,
174883
+ maxOutputTokens: options.maxOutputTokens || void 0
174829
174884
  };
174830
174885
  }
174831
174886
 
@@ -174993,9 +175048,15 @@ var LocalExecutor = class {
174993
175048
  };
174994
175049
 
174995
175050
  // nodes/ClaudeCode/transport/SshExecutor.ts
174996
- var import_ssh2 = require("ssh2");
174997
175051
  var import_node_fs = require("node:fs");
174998
175052
  var import_node_os = require("node:os");
175053
+ function loadSsh2() {
175054
+ return import("ssh2").catch(() => {
175055
+ throw new Error(
175056
+ 'SSH transport requires the "ssh2" package. Install it with: npm install ssh2'
175057
+ );
175058
+ });
175059
+ }
174999
175060
  var SshExecutor = class {
175000
175061
  credentials;
175001
175062
  constructor(credentials) {
@@ -175047,169 +175108,190 @@ var SshExecutor = class {
175047
175108
  * Execute a Claude Code command via SSH
175048
175109
  */
175049
175110
  execute(options) {
175050
- return new Promise((resolve) => {
175051
- const startTime = Date.now();
175052
- const remoteCmd = this.buildRemoteCommand(options);
175053
- let sshConfig;
175054
- try {
175055
- sshConfig = this.buildSshConfig();
175056
- } catch (err) {
175057
- const duration = Date.now() - startTime;
175058
- resolve(createErrorResult(err.message, 1, duration));
175059
- return;
175060
- }
175061
- const timeoutMs = options.timeout ? options.timeout * 1e3 : 3e5;
175062
- let stdout = "";
175063
- let stderr = "";
175064
- let connectionClosed = false;
175065
- const conn = new import_ssh2.Client();
175066
- const connectionTimeout = setTimeout(() => {
175067
- if (!connectionClosed) {
175068
- connectionClosed = true;
175069
- conn.end();
175070
- const duration = Date.now() - startTime;
175071
- resolve(createErrorResult("SSH connection timeout", 1, duration));
175072
- }
175073
- }, timeoutMs);
175074
- conn.on("ready", () => {
175075
- conn.exec(remoteCmd, { pty: false }, (err, stream2) => {
175076
- if (err) {
175077
- clearTimeout(connectionTimeout);
175111
+ const startTime = Date.now();
175112
+ const remoteCmd = this.buildRemoteCommand(options);
175113
+ let sshConfig;
175114
+ try {
175115
+ sshConfig = this.buildSshConfig();
175116
+ } catch (err) {
175117
+ const duration = Date.now() - startTime;
175118
+ return Promise.resolve(
175119
+ createErrorResult(err.message, 1, duration)
175120
+ );
175121
+ }
175122
+ return loadSsh2().then((ssh2) => {
175123
+ return new Promise((resolve) => {
175124
+ const timeoutMs = options.timeout ? options.timeout * 1e3 : 3e5;
175125
+ let stdout = "";
175126
+ let stderr = "";
175127
+ let connectionClosed = false;
175128
+ const conn = new ssh2.Client();
175129
+ const connectionTimeout = setTimeout(() => {
175130
+ if (!connectionClosed) {
175078
175131
  connectionClosed = true;
175079
175132
  conn.end();
175080
175133
  const duration = Date.now() - startTime;
175081
- resolve(
175082
- createErrorResult(`SSH exec error: ${err.message}`, 1, duration)
175083
- );
175084
- return;
175134
+ resolve(createErrorResult("SSH connection timeout", 1, duration));
175085
175135
  }
175086
- let exitCode = null;
175087
- let streamClosed = false;
175088
- const handleCompletion = () => {
175089
- if (streamClosed && exitCode !== null && !connectionClosed) {
175136
+ }, timeoutMs);
175137
+ conn.on("ready", () => {
175138
+ conn.exec(remoteCmd, { pty: false }, (err, stream2) => {
175139
+ if (err) {
175090
175140
  clearTimeout(connectionTimeout);
175091
175141
  connectionClosed = true;
175092
175142
  conn.end();
175093
175143
  const duration = Date.now() - startTime;
175094
- const code = exitCode ?? 0;
175095
- if (options.outputFormat === "json") {
175096
- const parsed = parseJsonOutput(stdout);
175097
- resolve(normalizeOutput(parsed, code, duration, stderr));
175098
- } else if (options.outputFormat === "stream-json") {
175099
- const { events, result } = parseStreamJsonOutput(stdout);
175100
- resolve(
175101
- normalizeStreamOutput(events, result, code, duration, stderr)
175102
- );
175103
- } else {
175104
- resolve({
175105
- success: code === 0,
175106
- sessionId: "",
175107
- output: stdout,
175108
- exitCode: code,
175109
- duration,
175110
- error: code !== 0 ? stderr : void 0
175111
- });
175112
- }
175113
- }
175114
- };
175115
- stream2.on("exit", (code) => {
175116
- exitCode = code ?? 0;
175117
- handleCompletion();
175118
- });
175119
- stream2.on("close", () => {
175120
- streamClosed = true;
175121
- if (exitCode === null) {
175122
- exitCode = 0;
175144
+ resolve(
175145
+ createErrorResult(
175146
+ `SSH exec error: ${err.message}`,
175147
+ 1,
175148
+ duration
175149
+ )
175150
+ );
175151
+ return;
175123
175152
  }
175124
- handleCompletion();
175125
- });
175126
- stream2.on("data", (data) => {
175127
- stdout += data.toString();
175128
- });
175129
- stream2.stderr.on("data", (data) => {
175130
- stderr += data.toString();
175153
+ let exitCode = null;
175154
+ let streamClosed = false;
175155
+ const handleCompletion = () => {
175156
+ if (streamClosed && exitCode !== null && !connectionClosed) {
175157
+ clearTimeout(connectionTimeout);
175158
+ connectionClosed = true;
175159
+ conn.end();
175160
+ const duration = Date.now() - startTime;
175161
+ const code = exitCode ?? 0;
175162
+ if (options.outputFormat === "json") {
175163
+ const parsed = parseJsonOutput(stdout);
175164
+ resolve(normalizeOutput(parsed, code, duration, stderr));
175165
+ } else if (options.outputFormat === "stream-json") {
175166
+ const { events, result } = parseStreamJsonOutput(stdout);
175167
+ resolve(
175168
+ normalizeStreamOutput(
175169
+ events,
175170
+ result,
175171
+ code,
175172
+ duration,
175173
+ stderr
175174
+ )
175175
+ );
175176
+ } else {
175177
+ resolve({
175178
+ success: code === 0,
175179
+ sessionId: "",
175180
+ output: stdout,
175181
+ exitCode: code,
175182
+ duration,
175183
+ error: code !== 0 ? stderr : void 0
175184
+ });
175185
+ }
175186
+ }
175187
+ };
175188
+ stream2.on("exit", (code) => {
175189
+ exitCode = code ?? 0;
175190
+ handleCompletion();
175191
+ });
175192
+ stream2.on("close", () => {
175193
+ streamClosed = true;
175194
+ if (exitCode === null) {
175195
+ exitCode = 0;
175196
+ }
175197
+ handleCompletion();
175198
+ });
175199
+ stream2.on("data", (data) => {
175200
+ stdout += data.toString();
175201
+ });
175202
+ stream2.stderr.on("data", (data) => {
175203
+ stderr += data.toString();
175204
+ });
175205
+ stream2.end();
175131
175206
  });
175132
- stream2.end();
175133
175207
  });
175208
+ conn.on("error", (err) => {
175209
+ clearTimeout(connectionTimeout);
175210
+ if (!connectionClosed) {
175211
+ connectionClosed = true;
175212
+ const duration = Date.now() - startTime;
175213
+ resolve(
175214
+ createErrorResult(
175215
+ `SSH connection error: ${err.message}`,
175216
+ 1,
175217
+ duration
175218
+ )
175219
+ );
175220
+ }
175221
+ });
175222
+ conn.connect(sshConfig);
175134
175223
  });
175135
- conn.on("error", (err) => {
175136
- clearTimeout(connectionTimeout);
175137
- if (!connectionClosed) {
175138
- connectionClosed = true;
175139
- const duration = Date.now() - startTime;
175140
- resolve(
175141
- createErrorResult(
175142
- `SSH connection error: ${err.message}`,
175143
- 1,
175144
- duration
175145
- )
175146
- );
175147
- }
175148
- });
175149
- conn.connect(sshConfig);
175224
+ }).catch((err) => {
175225
+ const duration = Date.now() - startTime;
175226
+ return createErrorResult(err.message, 1, duration);
175150
175227
  });
175151
175228
  }
175152
175229
  /**
175153
175230
  * Test SSH connection and Claude Code availability
175154
175231
  */
175155
175232
  testConnection() {
175156
- return new Promise((resolve) => {
175157
- let sshConfig;
175158
- try {
175159
- sshConfig = this.buildSshConfig();
175160
- } catch {
175161
- resolve(false);
175162
- return;
175163
- }
175164
- const conn = new import_ssh2.Client();
175165
- let resolved = false;
175166
- const timeout = setTimeout(() => {
175167
- if (!resolved) {
175168
- resolved = true;
175169
- conn.end();
175170
- resolve(false);
175171
- }
175172
- }, 1e4);
175173
- conn.on("ready", () => {
175174
- const claudePath = this.credentials.claudePath || "claude";
175175
- conn.exec(`${claudePath} --version`, { pty: false }, (err, stream2) => {
175176
- if (err) {
175177
- clearTimeout(timeout);
175178
- if (!resolved) {
175179
- resolved = true;
175180
- conn.end();
175181
- resolve(false);
175233
+ let sshConfig;
175234
+ try {
175235
+ sshConfig = this.buildSshConfig();
175236
+ } catch {
175237
+ return Promise.resolve(false);
175238
+ }
175239
+ return loadSsh2().then((ssh2) => {
175240
+ return new Promise((resolve) => {
175241
+ const conn = new ssh2.Client();
175242
+ let resolved = false;
175243
+ const timeout = setTimeout(() => {
175244
+ if (!resolved) {
175245
+ resolved = true;
175246
+ conn.end();
175247
+ resolve(false);
175248
+ }
175249
+ }, 1e4);
175250
+ conn.on("ready", () => {
175251
+ const claudePath = this.credentials.claudePath || "claude";
175252
+ conn.exec(
175253
+ `${claudePath} --version`,
175254
+ { pty: false },
175255
+ (err, stream2) => {
175256
+ if (err) {
175257
+ clearTimeout(timeout);
175258
+ if (!resolved) {
175259
+ resolved = true;
175260
+ conn.end();
175261
+ resolve(false);
175262
+ }
175263
+ return;
175264
+ }
175265
+ stream2.on("exit", (code) => {
175266
+ clearTimeout(timeout);
175267
+ if (!resolved) {
175268
+ resolved = true;
175269
+ conn.end();
175270
+ resolve(code === 0);
175271
+ }
175272
+ });
175273
+ stream2.on("close", () => {
175274
+ clearTimeout(timeout);
175275
+ if (!resolved) {
175276
+ resolved = true;
175277
+ conn.end();
175278
+ resolve(true);
175279
+ }
175280
+ });
175281
+ stream2.end();
175182
175282
  }
175183
- return;
175283
+ );
175284
+ });
175285
+ conn.on("error", () => {
175286
+ clearTimeout(timeout);
175287
+ if (!resolved) {
175288
+ resolved = true;
175289
+ resolve(false);
175184
175290
  }
175185
- stream2.on("exit", (code) => {
175186
- clearTimeout(timeout);
175187
- if (!resolved) {
175188
- resolved = true;
175189
- conn.end();
175190
- resolve(code === 0);
175191
- }
175192
- });
175193
- stream2.on("close", () => {
175194
- clearTimeout(timeout);
175195
- if (!resolved) {
175196
- resolved = true;
175197
- conn.end();
175198
- resolve(true);
175199
- }
175200
- });
175201
- stream2.end();
175202
175291
  });
175292
+ conn.connect(sshConfig);
175203
175293
  });
175204
- conn.on("error", () => {
175205
- clearTimeout(timeout);
175206
- if (!resolved) {
175207
- resolved = true;
175208
- resolve(false);
175209
- }
175210
- });
175211
- conn.connect(sshConfig);
175212
- });
175294
+ }).catch(() => false);
175213
175295
  }
175214
175296
  };
175215
175297