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.
@@ -174303,6 +174303,18 @@ var optionsDescription = [
174303
174303
  default: "json",
174304
174304
  description: "Output format for Claude Code response. Stream JSON captures all tool interactions as streaming events."
174305
174305
  },
174306
+ {
174307
+ displayName: "Reasoning Effort",
174308
+ name: "effort",
174309
+ type: "options",
174310
+ options: [
174311
+ { name: "Low", value: "low" },
174312
+ { name: "Medium", value: "medium" },
174313
+ { name: "High", value: "high" }
174314
+ ],
174315
+ default: "high",
174316
+ 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)."
174317
+ },
174306
174318
  {
174307
174319
  displayName: "Max Turns",
174308
174320
  name: "maxTurns",
@@ -174317,6 +174329,25 @@ var optionsDescription = [
174317
174329
  default: 300,
174318
174330
  description: "Execution timeout in seconds. Maximum: 3600 (1 hour)."
174319
174331
  },
174332
+ {
174333
+ displayName: "System Prompt Mode",
174334
+ name: "systemPromptMode",
174335
+ type: "options",
174336
+ options: [
174337
+ {
174338
+ name: "Append",
174339
+ value: "append",
174340
+ description: "Append to Claude Code default system prompt"
174341
+ },
174342
+ {
174343
+ name: "Replace",
174344
+ value: "replace",
174345
+ description: "Replace the entire Claude Code default system prompt"
174346
+ }
174347
+ ],
174348
+ default: "append",
174349
+ description: "Whether to append to or replace the default Claude Code system prompt. Replace gives full control over system instructions."
174350
+ },
174320
174351
  {
174321
174352
  displayName: "System Prompt",
174322
174353
  name: "systemPrompt",
@@ -174326,7 +174357,7 @@ var optionsDescription = [
174326
174357
  },
174327
174358
  default: "",
174328
174359
  placeholder: "You are a helpful code reviewer...",
174329
- description: "Additional system prompt to append to Claude Code default system prompt"
174360
+ description: "System prompt text. Behavior depends on System Prompt Mode: Append adds to the default prompt, Replace overrides it entirely."
174330
174361
  },
174331
174362
  {
174332
174363
  displayName: "System Prompt File",
@@ -174334,7 +174365,7 @@ var optionsDescription = [
174334
174365
  type: "string",
174335
174366
  default: "",
174336
174367
  placeholder: "/path/to/system-prompt.txt",
174337
- 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."
174368
+ 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."
174338
174369
  },
174339
174370
  {
174340
174371
  displayName: "Verbose",
@@ -174350,6 +174381,13 @@ var optionsDescription = [
174350
174381
  default: 0,
174351
174382
  description: "Maximum dollar amount to spend before stopping execution. 0 means unlimited. Critical for controlling costs in automated workflows."
174352
174383
  },
174384
+ {
174385
+ displayName: "Max Output Tokens",
174386
+ name: "maxOutputTokens",
174387
+ type: "number",
174388
+ default: 0,
174389
+ 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."
174390
+ },
174353
174391
  {
174354
174392
  displayName: "JSON Schema",
174355
174393
  name: "jsonSchema",
@@ -174447,14 +174485,25 @@ function buildCommand(options, credentials) {
174447
174485
  );
174448
174486
  }
174449
174487
  if (options.systemPrompt) {
174450
- args.push("--append-system-prompt", options.systemPrompt);
174488
+ if (options.systemPromptMode === "replace") {
174489
+ args.push("--system-prompt", options.systemPrompt);
174490
+ } else {
174491
+ args.push("--append-system-prompt", options.systemPrompt);
174492
+ }
174451
174493
  }
174452
174494
  if (options.systemPromptFile) {
174453
- args.push("--append-system-prompt-file", options.systemPromptFile);
174495
+ if (options.systemPromptMode === "replace") {
174496
+ args.push("--system-prompt-file", options.systemPromptFile);
174497
+ } else {
174498
+ args.push("--append-system-prompt-file", options.systemPromptFile);
174499
+ }
174454
174500
  }
174455
174501
  if (options.verbose && options.outputFormat !== "stream-json") {
174456
174502
  args.push("--verbose");
174457
174503
  }
174504
+ if (options.effort && options.effort !== "high") {
174505
+ args.push("--effort", options.effort);
174506
+ }
174458
174507
  if (options.maxBudgetUsd && options.maxBudgetUsd > 0) {
174459
174508
  args.push("--max-budget-usd", String(options.maxBudgetUsd));
174460
174509
  }
@@ -174508,6 +174557,9 @@ function buildCommand(options, credentials) {
174508
174557
  if (options.extendedContext === false) {
174509
174558
  env.CLAUDE_CODE_DISABLE_1M_CONTEXT = "1";
174510
174559
  }
174560
+ if (options.maxOutputTokens && options.maxOutputTokens > 0) {
174561
+ env.CLAUDE_CODE_MAX_OUTPUT_TOKENS = String(options.maxOutputTokens);
174562
+ }
174511
174563
  if ("envVars" in credentials && credentials.envVars) {
174512
174564
  const envVarsString = credentials.envVars;
174513
174565
  if (envVarsString && envVarsString !== "{}") {
@@ -174811,6 +174863,7 @@ function buildExecutionOptions(context, itemIndex, operation) {
174811
174863
  timeout: options.timeout || 300,
174812
174864
  systemPrompt: options.systemPrompt || void 0,
174813
174865
  systemPromptFile: options.systemPromptFile || void 0,
174866
+ systemPromptMode: options.systemPromptMode || void 0,
174814
174867
  verbose: options.verbose || void 0,
174815
174868
  maxBudgetUsd: options.maxBudgetUsd || void 0,
174816
174869
  jsonSchema: options.jsonSchema || void 0,
@@ -174818,7 +174871,9 @@ function buildExecutionOptions(context, itemIndex, operation) {
174818
174871
  agents,
174819
174872
  mcpConfig,
174820
174873
  extendedContext: options.extendedContext !== false,
174821
- worktree: options.worktreeEnabled ? options.worktreeName || "" : void 0
174874
+ worktree: options.worktreeEnabled ? options.worktreeName || "" : void 0,
174875
+ effort: options.effort && options.effort !== "high" ? options.effort : void 0,
174876
+ maxOutputTokens: options.maxOutputTokens || void 0
174822
174877
  };
174823
174878
  }
174824
174879
 
@@ -174986,9 +175041,15 @@ var LocalExecutor = class {
174986
175041
  };
174987
175042
 
174988
175043
  // nodes/ClaudeCode/transport/SshExecutor.ts
174989
- var import_ssh2 = require("ssh2");
174990
175044
  var import_node_fs = require("node:fs");
174991
175045
  var import_node_os = require("node:os");
175046
+ function loadSsh2() {
175047
+ return import("ssh2").catch(() => {
175048
+ throw new Error(
175049
+ 'SSH transport requires the "ssh2" package. Install it with: npm install ssh2'
175050
+ );
175051
+ });
175052
+ }
174992
175053
  var SshExecutor = class {
174993
175054
  credentials;
174994
175055
  constructor(credentials) {
@@ -175040,169 +175101,190 @@ var SshExecutor = class {
175040
175101
  * Execute a Claude Code command via SSH
175041
175102
  */
175042
175103
  execute(options) {
175043
- return new Promise((resolve) => {
175044
- const startTime = Date.now();
175045
- const remoteCmd = this.buildRemoteCommand(options);
175046
- let sshConfig;
175047
- try {
175048
- sshConfig = this.buildSshConfig();
175049
- } catch (err) {
175050
- const duration = Date.now() - startTime;
175051
- resolve(createErrorResult(err.message, 1, duration));
175052
- return;
175053
- }
175054
- const timeoutMs = options.timeout ? options.timeout * 1e3 : 3e5;
175055
- let stdout = "";
175056
- let stderr = "";
175057
- let connectionClosed = false;
175058
- const conn = new import_ssh2.Client();
175059
- const connectionTimeout = setTimeout(() => {
175060
- if (!connectionClosed) {
175061
- connectionClosed = true;
175062
- conn.end();
175063
- const duration = Date.now() - startTime;
175064
- resolve(createErrorResult("SSH connection timeout", 1, duration));
175065
- }
175066
- }, timeoutMs);
175067
- conn.on("ready", () => {
175068
- conn.exec(remoteCmd, { pty: false }, (err, stream2) => {
175069
- if (err) {
175070
- clearTimeout(connectionTimeout);
175104
+ const startTime = Date.now();
175105
+ const remoteCmd = this.buildRemoteCommand(options);
175106
+ let sshConfig;
175107
+ try {
175108
+ sshConfig = this.buildSshConfig();
175109
+ } catch (err) {
175110
+ const duration = Date.now() - startTime;
175111
+ return Promise.resolve(
175112
+ createErrorResult(err.message, 1, duration)
175113
+ );
175114
+ }
175115
+ return loadSsh2().then((ssh2) => {
175116
+ return new Promise((resolve) => {
175117
+ const timeoutMs = options.timeout ? options.timeout * 1e3 : 3e5;
175118
+ let stdout = "";
175119
+ let stderr = "";
175120
+ let connectionClosed = false;
175121
+ const conn = new ssh2.Client();
175122
+ const connectionTimeout = setTimeout(() => {
175123
+ if (!connectionClosed) {
175071
175124
  connectionClosed = true;
175072
175125
  conn.end();
175073
175126
  const duration = Date.now() - startTime;
175074
- resolve(
175075
- createErrorResult(`SSH exec error: ${err.message}`, 1, duration)
175076
- );
175077
- return;
175127
+ resolve(createErrorResult("SSH connection timeout", 1, duration));
175078
175128
  }
175079
- let exitCode = null;
175080
- let streamClosed = false;
175081
- const handleCompletion = () => {
175082
- if (streamClosed && exitCode !== null && !connectionClosed) {
175129
+ }, timeoutMs);
175130
+ conn.on("ready", () => {
175131
+ conn.exec(remoteCmd, { pty: false }, (err, stream2) => {
175132
+ if (err) {
175083
175133
  clearTimeout(connectionTimeout);
175084
175134
  connectionClosed = true;
175085
175135
  conn.end();
175086
175136
  const duration = Date.now() - startTime;
175087
- const code = exitCode ?? 0;
175088
- if (options.outputFormat === "json") {
175089
- const parsed = parseJsonOutput(stdout);
175090
- resolve(normalizeOutput(parsed, code, duration, stderr));
175091
- } else if (options.outputFormat === "stream-json") {
175092
- const { events, result } = parseStreamJsonOutput(stdout);
175093
- resolve(
175094
- normalizeStreamOutput(events, result, code, duration, stderr)
175095
- );
175096
- } else {
175097
- resolve({
175098
- success: code === 0,
175099
- sessionId: "",
175100
- output: stdout,
175101
- exitCode: code,
175102
- duration,
175103
- error: code !== 0 ? stderr : void 0
175104
- });
175105
- }
175106
- }
175107
- };
175108
- stream2.on("exit", (code) => {
175109
- exitCode = code ?? 0;
175110
- handleCompletion();
175111
- });
175112
- stream2.on("close", () => {
175113
- streamClosed = true;
175114
- if (exitCode === null) {
175115
- exitCode = 0;
175137
+ resolve(
175138
+ createErrorResult(
175139
+ `SSH exec error: ${err.message}`,
175140
+ 1,
175141
+ duration
175142
+ )
175143
+ );
175144
+ return;
175116
175145
  }
175117
- handleCompletion();
175118
- });
175119
- stream2.on("data", (data) => {
175120
- stdout += data.toString();
175121
- });
175122
- stream2.stderr.on("data", (data) => {
175123
- stderr += data.toString();
175146
+ let exitCode = null;
175147
+ let streamClosed = false;
175148
+ const handleCompletion = () => {
175149
+ if (streamClosed && exitCode !== null && !connectionClosed) {
175150
+ clearTimeout(connectionTimeout);
175151
+ connectionClosed = true;
175152
+ conn.end();
175153
+ const duration = Date.now() - startTime;
175154
+ const code = exitCode ?? 0;
175155
+ if (options.outputFormat === "json") {
175156
+ const parsed = parseJsonOutput(stdout);
175157
+ resolve(normalizeOutput(parsed, code, duration, stderr));
175158
+ } else if (options.outputFormat === "stream-json") {
175159
+ const { events, result } = parseStreamJsonOutput(stdout);
175160
+ resolve(
175161
+ normalizeStreamOutput(
175162
+ events,
175163
+ result,
175164
+ code,
175165
+ duration,
175166
+ stderr
175167
+ )
175168
+ );
175169
+ } else {
175170
+ resolve({
175171
+ success: code === 0,
175172
+ sessionId: "",
175173
+ output: stdout,
175174
+ exitCode: code,
175175
+ duration,
175176
+ error: code !== 0 ? stderr : void 0
175177
+ });
175178
+ }
175179
+ }
175180
+ };
175181
+ stream2.on("exit", (code) => {
175182
+ exitCode = code ?? 0;
175183
+ handleCompletion();
175184
+ });
175185
+ stream2.on("close", () => {
175186
+ streamClosed = true;
175187
+ if (exitCode === null) {
175188
+ exitCode = 0;
175189
+ }
175190
+ handleCompletion();
175191
+ });
175192
+ stream2.on("data", (data) => {
175193
+ stdout += data.toString();
175194
+ });
175195
+ stream2.stderr.on("data", (data) => {
175196
+ stderr += data.toString();
175197
+ });
175198
+ stream2.end();
175124
175199
  });
175125
- stream2.end();
175126
175200
  });
175201
+ conn.on("error", (err) => {
175202
+ clearTimeout(connectionTimeout);
175203
+ if (!connectionClosed) {
175204
+ connectionClosed = true;
175205
+ const duration = Date.now() - startTime;
175206
+ resolve(
175207
+ createErrorResult(
175208
+ `SSH connection error: ${err.message}`,
175209
+ 1,
175210
+ duration
175211
+ )
175212
+ );
175213
+ }
175214
+ });
175215
+ conn.connect(sshConfig);
175127
175216
  });
175128
- conn.on("error", (err) => {
175129
- clearTimeout(connectionTimeout);
175130
- if (!connectionClosed) {
175131
- connectionClosed = true;
175132
- const duration = Date.now() - startTime;
175133
- resolve(
175134
- createErrorResult(
175135
- `SSH connection error: ${err.message}`,
175136
- 1,
175137
- duration
175138
- )
175139
- );
175140
- }
175141
- });
175142
- conn.connect(sshConfig);
175217
+ }).catch((err) => {
175218
+ const duration = Date.now() - startTime;
175219
+ return createErrorResult(err.message, 1, duration);
175143
175220
  });
175144
175221
  }
175145
175222
  /**
175146
175223
  * Test SSH connection and Claude Code availability
175147
175224
  */
175148
175225
  testConnection() {
175149
- return new Promise((resolve) => {
175150
- let sshConfig;
175151
- try {
175152
- sshConfig = this.buildSshConfig();
175153
- } catch {
175154
- resolve(false);
175155
- return;
175156
- }
175157
- const conn = new import_ssh2.Client();
175158
- let resolved = false;
175159
- const timeout = setTimeout(() => {
175160
- if (!resolved) {
175161
- resolved = true;
175162
- conn.end();
175163
- resolve(false);
175164
- }
175165
- }, 1e4);
175166
- conn.on("ready", () => {
175167
- const claudePath = this.credentials.claudePath || "claude";
175168
- conn.exec(`${claudePath} --version`, { pty: false }, (err, stream2) => {
175169
- if (err) {
175170
- clearTimeout(timeout);
175171
- if (!resolved) {
175172
- resolved = true;
175173
- conn.end();
175174
- resolve(false);
175226
+ let sshConfig;
175227
+ try {
175228
+ sshConfig = this.buildSshConfig();
175229
+ } catch {
175230
+ return Promise.resolve(false);
175231
+ }
175232
+ return loadSsh2().then((ssh2) => {
175233
+ return new Promise((resolve) => {
175234
+ const conn = new ssh2.Client();
175235
+ let resolved = false;
175236
+ const timeout = setTimeout(() => {
175237
+ if (!resolved) {
175238
+ resolved = true;
175239
+ conn.end();
175240
+ resolve(false);
175241
+ }
175242
+ }, 1e4);
175243
+ conn.on("ready", () => {
175244
+ const claudePath = this.credentials.claudePath || "claude";
175245
+ conn.exec(
175246
+ `${claudePath} --version`,
175247
+ { pty: false },
175248
+ (err, stream2) => {
175249
+ if (err) {
175250
+ clearTimeout(timeout);
175251
+ if (!resolved) {
175252
+ resolved = true;
175253
+ conn.end();
175254
+ resolve(false);
175255
+ }
175256
+ return;
175257
+ }
175258
+ stream2.on("exit", (code) => {
175259
+ clearTimeout(timeout);
175260
+ if (!resolved) {
175261
+ resolved = true;
175262
+ conn.end();
175263
+ resolve(code === 0);
175264
+ }
175265
+ });
175266
+ stream2.on("close", () => {
175267
+ clearTimeout(timeout);
175268
+ if (!resolved) {
175269
+ resolved = true;
175270
+ conn.end();
175271
+ resolve(true);
175272
+ }
175273
+ });
175274
+ stream2.end();
175175
175275
  }
175176
- return;
175276
+ );
175277
+ });
175278
+ conn.on("error", () => {
175279
+ clearTimeout(timeout);
175280
+ if (!resolved) {
175281
+ resolved = true;
175282
+ resolve(false);
175177
175283
  }
175178
- stream2.on("exit", (code) => {
175179
- clearTimeout(timeout);
175180
- if (!resolved) {
175181
- resolved = true;
175182
- conn.end();
175183
- resolve(code === 0);
175184
- }
175185
- });
175186
- stream2.on("close", () => {
175187
- clearTimeout(timeout);
175188
- if (!resolved) {
175189
- resolved = true;
175190
- conn.end();
175191
- resolve(true);
175192
- }
175193
- });
175194
- stream2.end();
175195
175284
  });
175285
+ conn.connect(sshConfig);
175196
175286
  });
175197
- conn.on("error", () => {
175198
- clearTimeout(timeout);
175199
- if (!resolved) {
175200
- resolved = true;
175201
- resolve(false);
175202
- }
175203
- });
175204
- conn.connect(sshConfig);
175205
- });
175287
+ }).catch(() => false);
175206
175288
  }
175207
175289
  };
175208
175290