n8n-nodes-claude-code-cli 1.6.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 +463 -147
- package/dist/index.js.map +3 -3
- package/dist/nodes/ClaudeCode/ClaudeCode.node.d.ts.map +1 -1
- package/dist/nodes/ClaudeCode/ClaudeCode.node.js +463 -147
- package/dist/nodes/ClaudeCode/ClaudeCode.node.js.map +3 -3
- package/dist/nodes/ClaudeCode/descriptions/index.d.ts +1 -0
- package/dist/nodes/ClaudeCode/descriptions/index.d.ts.map +1 -1
- package/dist/nodes/ClaudeCode/descriptions/mcpServersDescription.d.ts +3 -0
- package/dist/nodes/ClaudeCode/descriptions/mcpServersDescription.d.ts.map +1 -0
- package/dist/nodes/ClaudeCode/descriptions/optionsDescription.d.ts.map +1 -1
- package/dist/nodes/ClaudeCode/interfaces/ClaudeCodeTypes.d.ts +40 -0
- package/dist/nodes/ClaudeCode/interfaces/ClaudeCodeTypes.d.ts.map +1 -1
- package/dist/nodes/ClaudeCode/interfaces/index.d.ts +1 -1
- package/dist/nodes/ClaudeCode/interfaces/index.d.ts.map +1 -1
- package/dist/nodes/ClaudeCode/transport/SshExecutor.d.ts.map +1 -1
- package/dist/nodes/ClaudeCode/transport/k8s/podSpecBuilder.d.ts.map +1 -1
- package/dist/nodes/ClaudeCode/utils/commandBuilder.d.ts.map +1 -1
- package/dist/nodes/ClaudeCode/utils/optionsBuilder.d.ts.map +1 -1
- package/package.json +3 -5
package/dist/index.js
CHANGED
|
@@ -174139,6 +174139,148 @@ var agentsDescription = [
|
|
|
174139
174139
|
}
|
|
174140
174140
|
];
|
|
174141
174141
|
|
|
174142
|
+
// nodes/ClaudeCode/descriptions/mcpServersDescription.ts
|
|
174143
|
+
var mcpServersDescription = [
|
|
174144
|
+
{
|
|
174145
|
+
displayName: "MCP Servers",
|
|
174146
|
+
name: "mcpServers",
|
|
174147
|
+
type: "fixedCollection",
|
|
174148
|
+
typeOptions: {
|
|
174149
|
+
multipleValues: true,
|
|
174150
|
+
multipleValueButtonText: "Add MCP Server"
|
|
174151
|
+
},
|
|
174152
|
+
default: { serversList: [] },
|
|
174153
|
+
displayOptions: {
|
|
174154
|
+
show: {
|
|
174155
|
+
operation: ["executePrompt", "executeWithContext"]
|
|
174156
|
+
}
|
|
174157
|
+
},
|
|
174158
|
+
options: [
|
|
174159
|
+
{
|
|
174160
|
+
name: "serversList",
|
|
174161
|
+
displayName: "Servers",
|
|
174162
|
+
values: [
|
|
174163
|
+
{
|
|
174164
|
+
displayName: "Server Name",
|
|
174165
|
+
name: "name",
|
|
174166
|
+
type: "string",
|
|
174167
|
+
default: "",
|
|
174168
|
+
required: true,
|
|
174169
|
+
placeholder: "slack",
|
|
174170
|
+
description: "Unique identifier for this MCP server."
|
|
174171
|
+
},
|
|
174172
|
+
{
|
|
174173
|
+
displayName: "Transport Type",
|
|
174174
|
+
name: "serverType",
|
|
174175
|
+
type: "options",
|
|
174176
|
+
options: [
|
|
174177
|
+
{ name: "Stdio", value: "stdio" },
|
|
174178
|
+
{ name: "HTTP", value: "http" }
|
|
174179
|
+
],
|
|
174180
|
+
default: "stdio",
|
|
174181
|
+
description: "Transport protocol for communicating with the MCP server."
|
|
174182
|
+
},
|
|
174183
|
+
{
|
|
174184
|
+
displayName: "Command",
|
|
174185
|
+
name: "command",
|
|
174186
|
+
type: "string",
|
|
174187
|
+
default: "",
|
|
174188
|
+
required: true,
|
|
174189
|
+
placeholder: "npx -y @modelcontextprotocol/server-slack",
|
|
174190
|
+
description: "Full command to launch the MCP server. Arguments after the executable are automatically extracted (e.g. 'npx -y @org/server --key val' becomes command='npx', args=['-y','@org/server','--key','val']).",
|
|
174191
|
+
displayOptions: {
|
|
174192
|
+
show: {
|
|
174193
|
+
serverType: ["stdio"]
|
|
174194
|
+
}
|
|
174195
|
+
}
|
|
174196
|
+
},
|
|
174197
|
+
{
|
|
174198
|
+
displayName: "Arguments",
|
|
174199
|
+
name: "args",
|
|
174200
|
+
type: "string",
|
|
174201
|
+
default: "",
|
|
174202
|
+
placeholder: "--port,3000,--verbose",
|
|
174203
|
+
description: "Comma-separated arguments to pass to the command.",
|
|
174204
|
+
displayOptions: {
|
|
174205
|
+
show: {
|
|
174206
|
+
serverType: ["stdio"]
|
|
174207
|
+
}
|
|
174208
|
+
}
|
|
174209
|
+
},
|
|
174210
|
+
{
|
|
174211
|
+
displayName: "Environment Variables",
|
|
174212
|
+
name: "env",
|
|
174213
|
+
type: "string",
|
|
174214
|
+
typeOptions: { rows: 2 },
|
|
174215
|
+
default: "",
|
|
174216
|
+
placeholder: '{"SLACK_TOKEN": "xoxb-..."}',
|
|
174217
|
+
description: "JSON object of environment variables for the server process.",
|
|
174218
|
+
displayOptions: {
|
|
174219
|
+
show: {
|
|
174220
|
+
serverType: ["stdio"]
|
|
174221
|
+
}
|
|
174222
|
+
}
|
|
174223
|
+
},
|
|
174224
|
+
{
|
|
174225
|
+
displayName: "URL",
|
|
174226
|
+
name: "url",
|
|
174227
|
+
type: "string",
|
|
174228
|
+
default: "",
|
|
174229
|
+
required: true,
|
|
174230
|
+
placeholder: "https://mcp.example.com/sse",
|
|
174231
|
+
description: "HTTP endpoint URL of the MCP server.",
|
|
174232
|
+
displayOptions: {
|
|
174233
|
+
show: {
|
|
174234
|
+
serverType: ["http"]
|
|
174235
|
+
}
|
|
174236
|
+
}
|
|
174237
|
+
},
|
|
174238
|
+
{
|
|
174239
|
+
displayName: "Headers",
|
|
174240
|
+
name: "headers",
|
|
174241
|
+
type: "string",
|
|
174242
|
+
typeOptions: { rows: 2 },
|
|
174243
|
+
default: "",
|
|
174244
|
+
placeholder: '{"Authorization": "Bearer ..."}',
|
|
174245
|
+
description: "JSON object of HTTP headers to send with requests.",
|
|
174246
|
+
displayOptions: {
|
|
174247
|
+
show: {
|
|
174248
|
+
serverType: ["http"]
|
|
174249
|
+
}
|
|
174250
|
+
}
|
|
174251
|
+
}
|
|
174252
|
+
]
|
|
174253
|
+
}
|
|
174254
|
+
],
|
|
174255
|
+
description: "Define MCP servers to inject into the Claude Code session. Servers provide external tools (Slack, GitHub, databases, etc.)."
|
|
174256
|
+
},
|
|
174257
|
+
{
|
|
174258
|
+
displayName: "MCP Config File Paths",
|
|
174259
|
+
name: "mcpConfigFilePaths",
|
|
174260
|
+
type: "string",
|
|
174261
|
+
default: "",
|
|
174262
|
+
placeholder: "/path/to/mcp-config.json, /path/to/another.json",
|
|
174263
|
+
description: "Comma-separated file paths to MCP configuration files. Each file is passed as a separate --mcp-config argument.",
|
|
174264
|
+
displayOptions: {
|
|
174265
|
+
show: {
|
|
174266
|
+
operation: ["executePrompt", "executeWithContext"]
|
|
174267
|
+
}
|
|
174268
|
+
}
|
|
174269
|
+
},
|
|
174270
|
+
{
|
|
174271
|
+
displayName: "MCP Strict Mode",
|
|
174272
|
+
name: "mcpStrictMode",
|
|
174273
|
+
type: "boolean",
|
|
174274
|
+
default: false,
|
|
174275
|
+
description: "Whether to enable strict MCP config mode. When enabled, Claude Code will fail if any MCP server cannot be started.",
|
|
174276
|
+
displayOptions: {
|
|
174277
|
+
show: {
|
|
174278
|
+
operation: ["executePrompt", "executeWithContext"]
|
|
174279
|
+
}
|
|
174280
|
+
}
|
|
174281
|
+
}
|
|
174282
|
+
];
|
|
174283
|
+
|
|
174142
174284
|
// nodes/ClaudeCode/descriptions/optionsDescription.ts
|
|
174143
174285
|
var optionsDescription = [
|
|
174144
174286
|
{
|
|
@@ -174168,6 +174310,18 @@ var optionsDescription = [
|
|
|
174168
174310
|
default: "json",
|
|
174169
174311
|
description: "Output format for Claude Code response. Stream JSON captures all tool interactions as streaming events."
|
|
174170
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
|
+
},
|
|
174171
174325
|
{
|
|
174172
174326
|
displayName: "Max Turns",
|
|
174173
174327
|
name: "maxTurns",
|
|
@@ -174182,6 +174336,25 @@ var optionsDescription = [
|
|
|
174182
174336
|
default: 300,
|
|
174183
174337
|
description: "Execution timeout in seconds. Maximum: 3600 (1 hour)."
|
|
174184
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
|
+
},
|
|
174185
174358
|
{
|
|
174186
174359
|
displayName: "System Prompt",
|
|
174187
174360
|
name: "systemPrompt",
|
|
@@ -174191,7 +174364,7 @@ var optionsDescription = [
|
|
|
174191
174364
|
},
|
|
174192
174365
|
default: "",
|
|
174193
174366
|
placeholder: "You are a helpful code reviewer...",
|
|
174194
|
-
description: "
|
|
174367
|
+
description: "System prompt text. Behavior depends on System Prompt Mode: Append adds to the default prompt, Replace overrides it entirely."
|
|
174195
174368
|
},
|
|
174196
174369
|
{
|
|
174197
174370
|
displayName: "System Prompt File",
|
|
@@ -174199,7 +174372,7 @@ var optionsDescription = [
|
|
|
174199
174372
|
type: "string",
|
|
174200
174373
|
default: "",
|
|
174201
174374
|
placeholder: "/path/to/system-prompt.txt",
|
|
174202
|
-
description: "Path to a file containing
|
|
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."
|
|
174203
174376
|
},
|
|
174204
174377
|
{
|
|
174205
174378
|
displayName: "Verbose",
|
|
@@ -174215,6 +174388,13 @@ var optionsDescription = [
|
|
|
174215
174388
|
default: 0,
|
|
174216
174389
|
description: "Maximum dollar amount to spend before stopping execution. 0 means unlimited. Critical for controlling costs in automated workflows."
|
|
174217
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
|
+
},
|
|
174218
174398
|
{
|
|
174219
174399
|
displayName: "JSON Schema",
|
|
174220
174400
|
name: "jsonSchema",
|
|
@@ -174312,14 +174492,25 @@ function buildCommand(options, credentials) {
|
|
|
174312
174492
|
);
|
|
174313
174493
|
}
|
|
174314
174494
|
if (options.systemPrompt) {
|
|
174315
|
-
|
|
174495
|
+
if (options.systemPromptMode === "replace") {
|
|
174496
|
+
args.push("--system-prompt", options.systemPrompt);
|
|
174497
|
+
} else {
|
|
174498
|
+
args.push("--append-system-prompt", options.systemPrompt);
|
|
174499
|
+
}
|
|
174316
174500
|
}
|
|
174317
174501
|
if (options.systemPromptFile) {
|
|
174318
|
-
|
|
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
|
+
}
|
|
174319
174507
|
}
|
|
174320
174508
|
if (options.verbose && options.outputFormat !== "stream-json") {
|
|
174321
174509
|
args.push("--verbose");
|
|
174322
174510
|
}
|
|
174511
|
+
if (options.effort && options.effort !== "high") {
|
|
174512
|
+
args.push("--effort", options.effort);
|
|
174513
|
+
}
|
|
174323
174514
|
if (options.maxBudgetUsd && options.maxBudgetUsd > 0) {
|
|
174324
174515
|
args.push("--max-budget-usd", String(options.maxBudgetUsd));
|
|
174325
174516
|
}
|
|
@@ -174351,12 +174542,31 @@ function buildCommand(options, credentials) {
|
|
|
174351
174542
|
if (options.agents && Object.keys(options.agents).length > 0) {
|
|
174352
174543
|
args.push("--agents", JSON.stringify(options.agents));
|
|
174353
174544
|
}
|
|
174545
|
+
if (options.mcpConfig) {
|
|
174546
|
+
if (options.mcpConfig.inlineServers && Object.keys(options.mcpConfig.inlineServers).length > 0) {
|
|
174547
|
+
args.push(
|
|
174548
|
+
"--mcp-config",
|
|
174549
|
+
JSON.stringify({ mcpServers: options.mcpConfig.inlineServers })
|
|
174550
|
+
);
|
|
174551
|
+
}
|
|
174552
|
+
if (options.mcpConfig.configFilePaths && options.mcpConfig.configFilePaths.length > 0) {
|
|
174553
|
+
for (const filePath of options.mcpConfig.configFilePaths) {
|
|
174554
|
+
args.push("--mcp-config", filePath);
|
|
174555
|
+
}
|
|
174556
|
+
}
|
|
174557
|
+
if (options.mcpConfig.strictMode) {
|
|
174558
|
+
args.push("--strict-mcp-config");
|
|
174559
|
+
}
|
|
174560
|
+
}
|
|
174354
174561
|
if (options.additionalArgs && options.additionalArgs.length > 0) {
|
|
174355
174562
|
args.push(...options.additionalArgs);
|
|
174356
174563
|
}
|
|
174357
174564
|
if (options.extendedContext === false) {
|
|
174358
174565
|
env.CLAUDE_CODE_DISABLE_1M_CONTEXT = "1";
|
|
174359
174566
|
}
|
|
174567
|
+
if (options.maxOutputTokens && options.maxOutputTokens > 0) {
|
|
174568
|
+
env.CLAUDE_CODE_MAX_OUTPUT_TOKENS = String(options.maxOutputTokens);
|
|
174569
|
+
}
|
|
174360
174570
|
if ("envVars" in credentials && credentials.envVars) {
|
|
174361
174571
|
const envVarsString = credentials.envVars;
|
|
174362
174572
|
if (envVarsString && envVarsString !== "{}") {
|
|
@@ -174589,6 +174799,63 @@ function buildExecutionOptions(context, itemIndex, operation) {
|
|
|
174589
174799
|
agents[agent.name] = def;
|
|
174590
174800
|
}
|
|
174591
174801
|
}
|
|
174802
|
+
const mcpServersData = context.getNodeParameter("mcpServers", itemIndex, {
|
|
174803
|
+
serversList: []
|
|
174804
|
+
});
|
|
174805
|
+
const mcpConfigFilePathsRaw = context.getNodeParameter(
|
|
174806
|
+
"mcpConfigFilePaths",
|
|
174807
|
+
itemIndex,
|
|
174808
|
+
""
|
|
174809
|
+
);
|
|
174810
|
+
const mcpStrictMode = context.getNodeParameter(
|
|
174811
|
+
"mcpStrictMode",
|
|
174812
|
+
itemIndex,
|
|
174813
|
+
false
|
|
174814
|
+
);
|
|
174815
|
+
let mcpConfig;
|
|
174816
|
+
const hasInlineServers = mcpServersData.serversList && mcpServersData.serversList.length > 0;
|
|
174817
|
+
const configFilePaths = mcpConfigFilePathsRaw ? mcpConfigFilePathsRaw.split(",").map((p) => p.trim()).filter(Boolean) : [];
|
|
174818
|
+
const hasConfigFiles = configFilePaths.length > 0;
|
|
174819
|
+
if (hasInlineServers || hasConfigFiles || mcpStrictMode) {
|
|
174820
|
+
mcpConfig = {};
|
|
174821
|
+
if (hasInlineServers) {
|
|
174822
|
+
mcpConfig.inlineServers = {};
|
|
174823
|
+
for (const server of mcpServersData.serversList) {
|
|
174824
|
+
let def;
|
|
174825
|
+
if (server.serverType === "http") {
|
|
174826
|
+
def = {
|
|
174827
|
+
type: "http",
|
|
174828
|
+
url: server.url
|
|
174829
|
+
};
|
|
174830
|
+
if (server.headers) {
|
|
174831
|
+
def.headers = JSON.parse(server.headers);
|
|
174832
|
+
}
|
|
174833
|
+
} else {
|
|
174834
|
+
const commandParts = server.command.split(/\s+/).filter(Boolean);
|
|
174835
|
+
const executable = commandParts[0];
|
|
174836
|
+
const commandArgs = commandParts.slice(1);
|
|
174837
|
+
const explicitArgs = server.args ? server.args.split(",").map((a) => a.trim()).filter(Boolean) : [];
|
|
174838
|
+
const allArgs = [...commandArgs, ...explicitArgs];
|
|
174839
|
+
def = {
|
|
174840
|
+
command: executable
|
|
174841
|
+
};
|
|
174842
|
+
if (allArgs.length > 0) {
|
|
174843
|
+
def.args = allArgs;
|
|
174844
|
+
}
|
|
174845
|
+
if (server.env) {
|
|
174846
|
+
def.env = JSON.parse(server.env);
|
|
174847
|
+
}
|
|
174848
|
+
}
|
|
174849
|
+
mcpConfig.inlineServers[server.name] = def;
|
|
174850
|
+
}
|
|
174851
|
+
}
|
|
174852
|
+
if (hasConfigFiles) {
|
|
174853
|
+
mcpConfig.configFilePaths = configFilePaths;
|
|
174854
|
+
}
|
|
174855
|
+
if (mcpStrictMode) {
|
|
174856
|
+
mcpConfig.strictMode = true;
|
|
174857
|
+
}
|
|
174858
|
+
}
|
|
174592
174859
|
return {
|
|
174593
174860
|
prompt,
|
|
174594
174861
|
workingDirectory: options.workingDirectory,
|
|
@@ -174603,13 +174870,17 @@ function buildExecutionOptions(context, itemIndex, operation) {
|
|
|
174603
174870
|
timeout: options.timeout || 300,
|
|
174604
174871
|
systemPrompt: options.systemPrompt || void 0,
|
|
174605
174872
|
systemPromptFile: options.systemPromptFile || void 0,
|
|
174873
|
+
systemPromptMode: options.systemPromptMode || void 0,
|
|
174606
174874
|
verbose: options.verbose || void 0,
|
|
174607
174875
|
maxBudgetUsd: options.maxBudgetUsd || void 0,
|
|
174608
174876
|
jsonSchema: options.jsonSchema || void 0,
|
|
174609
174877
|
fallbackModel: options.fallbackModel || void 0,
|
|
174610
174878
|
agents,
|
|
174879
|
+
mcpConfig,
|
|
174611
174880
|
extendedContext: options.extendedContext !== false,
|
|
174612
|
-
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
|
|
174613
174884
|
};
|
|
174614
174885
|
}
|
|
174615
174886
|
|
|
@@ -174777,9 +175048,15 @@ var LocalExecutor = class {
|
|
|
174777
175048
|
};
|
|
174778
175049
|
|
|
174779
175050
|
// nodes/ClaudeCode/transport/SshExecutor.ts
|
|
174780
|
-
var import_ssh2 = require("ssh2");
|
|
174781
175051
|
var import_node_fs = require("node:fs");
|
|
174782
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
|
+
}
|
|
174783
175060
|
var SshExecutor = class {
|
|
174784
175061
|
credentials;
|
|
174785
175062
|
constructor(credentials) {
|
|
@@ -174831,169 +175108,190 @@ var SshExecutor = class {
|
|
|
174831
175108
|
* Execute a Claude Code command via SSH
|
|
174832
175109
|
*/
|
|
174833
175110
|
execute(options) {
|
|
174834
|
-
|
|
174835
|
-
|
|
174836
|
-
|
|
174837
|
-
|
|
174838
|
-
|
|
174839
|
-
|
|
174840
|
-
|
|
174841
|
-
|
|
174842
|
-
|
|
174843
|
-
|
|
174844
|
-
|
|
174845
|
-
|
|
174846
|
-
|
|
174847
|
-
|
|
174848
|
-
|
|
174849
|
-
|
|
174850
|
-
|
|
174851
|
-
|
|
174852
|
-
|
|
174853
|
-
|
|
174854
|
-
const duration = Date.now() - startTime;
|
|
174855
|
-
resolve(createErrorResult("SSH connection timeout", 1, duration));
|
|
174856
|
-
}
|
|
174857
|
-
}, timeoutMs);
|
|
174858
|
-
conn.on("ready", () => {
|
|
174859
|
-
conn.exec(remoteCmd, { pty: false }, (err, stream2) => {
|
|
174860
|
-
if (err) {
|
|
174861
|
-
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) {
|
|
174862
175131
|
connectionClosed = true;
|
|
174863
175132
|
conn.end();
|
|
174864
175133
|
const duration = Date.now() - startTime;
|
|
174865
|
-
resolve(
|
|
174866
|
-
createErrorResult(`SSH exec error: ${err.message}`, 1, duration)
|
|
174867
|
-
);
|
|
174868
|
-
return;
|
|
175134
|
+
resolve(createErrorResult("SSH connection timeout", 1, duration));
|
|
174869
175135
|
}
|
|
174870
|
-
|
|
174871
|
-
|
|
174872
|
-
|
|
174873
|
-
if (
|
|
175136
|
+
}, timeoutMs);
|
|
175137
|
+
conn.on("ready", () => {
|
|
175138
|
+
conn.exec(remoteCmd, { pty: false }, (err, stream2) => {
|
|
175139
|
+
if (err) {
|
|
174874
175140
|
clearTimeout(connectionTimeout);
|
|
174875
175141
|
connectionClosed = true;
|
|
174876
175142
|
conn.end();
|
|
174877
175143
|
const duration = Date.now() - startTime;
|
|
174878
|
-
|
|
174879
|
-
|
|
174880
|
-
|
|
174881
|
-
|
|
174882
|
-
|
|
174883
|
-
|
|
174884
|
-
|
|
174885
|
-
|
|
174886
|
-
);
|
|
174887
|
-
} else {
|
|
174888
|
-
resolve({
|
|
174889
|
-
success: code === 0,
|
|
174890
|
-
sessionId: "",
|
|
174891
|
-
output: stdout,
|
|
174892
|
-
exitCode: code,
|
|
174893
|
-
duration,
|
|
174894
|
-
error: code !== 0 ? stderr : void 0
|
|
174895
|
-
});
|
|
174896
|
-
}
|
|
174897
|
-
}
|
|
174898
|
-
};
|
|
174899
|
-
stream2.on("exit", (code) => {
|
|
174900
|
-
exitCode = code ?? 0;
|
|
174901
|
-
handleCompletion();
|
|
174902
|
-
});
|
|
174903
|
-
stream2.on("close", () => {
|
|
174904
|
-
streamClosed = true;
|
|
174905
|
-
if (exitCode === null) {
|
|
174906
|
-
exitCode = 0;
|
|
175144
|
+
resolve(
|
|
175145
|
+
createErrorResult(
|
|
175146
|
+
`SSH exec error: ${err.message}`,
|
|
175147
|
+
1,
|
|
175148
|
+
duration
|
|
175149
|
+
)
|
|
175150
|
+
);
|
|
175151
|
+
return;
|
|
174907
175152
|
}
|
|
174908
|
-
|
|
174909
|
-
|
|
174910
|
-
|
|
174911
|
-
|
|
174912
|
-
|
|
174913
|
-
|
|
174914
|
-
|
|
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();
|
|
174915
175206
|
});
|
|
174916
|
-
stream2.end();
|
|
174917
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);
|
|
174918
175223
|
});
|
|
174919
|
-
|
|
174920
|
-
|
|
174921
|
-
|
|
174922
|
-
connectionClosed = true;
|
|
174923
|
-
const duration = Date.now() - startTime;
|
|
174924
|
-
resolve(
|
|
174925
|
-
createErrorResult(
|
|
174926
|
-
`SSH connection error: ${err.message}`,
|
|
174927
|
-
1,
|
|
174928
|
-
duration
|
|
174929
|
-
)
|
|
174930
|
-
);
|
|
174931
|
-
}
|
|
174932
|
-
});
|
|
174933
|
-
conn.connect(sshConfig);
|
|
175224
|
+
}).catch((err) => {
|
|
175225
|
+
const duration = Date.now() - startTime;
|
|
175226
|
+
return createErrorResult(err.message, 1, duration);
|
|
174934
175227
|
});
|
|
174935
175228
|
}
|
|
174936
175229
|
/**
|
|
174937
175230
|
* Test SSH connection and Claude Code availability
|
|
174938
175231
|
*/
|
|
174939
175232
|
testConnection() {
|
|
174940
|
-
|
|
174941
|
-
|
|
174942
|
-
|
|
174943
|
-
|
|
174944
|
-
|
|
174945
|
-
|
|
174946
|
-
|
|
174947
|
-
|
|
174948
|
-
|
|
174949
|
-
|
|
174950
|
-
|
|
174951
|
-
|
|
174952
|
-
|
|
174953
|
-
|
|
174954
|
-
|
|
174955
|
-
|
|
174956
|
-
|
|
174957
|
-
|
|
174958
|
-
|
|
174959
|
-
|
|
174960
|
-
|
|
174961
|
-
|
|
174962
|
-
|
|
174963
|
-
|
|
174964
|
-
|
|
174965
|
-
|
|
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();
|
|
174966
175282
|
}
|
|
174967
|
-
|
|
175283
|
+
);
|
|
175284
|
+
});
|
|
175285
|
+
conn.on("error", () => {
|
|
175286
|
+
clearTimeout(timeout);
|
|
175287
|
+
if (!resolved) {
|
|
175288
|
+
resolved = true;
|
|
175289
|
+
resolve(false);
|
|
174968
175290
|
}
|
|
174969
|
-
stream2.on("exit", (code) => {
|
|
174970
|
-
clearTimeout(timeout);
|
|
174971
|
-
if (!resolved) {
|
|
174972
|
-
resolved = true;
|
|
174973
|
-
conn.end();
|
|
174974
|
-
resolve(code === 0);
|
|
174975
|
-
}
|
|
174976
|
-
});
|
|
174977
|
-
stream2.on("close", () => {
|
|
174978
|
-
clearTimeout(timeout);
|
|
174979
|
-
if (!resolved) {
|
|
174980
|
-
resolved = true;
|
|
174981
|
-
conn.end();
|
|
174982
|
-
resolve(true);
|
|
174983
|
-
}
|
|
174984
|
-
});
|
|
174985
|
-
stream2.end();
|
|
174986
175291
|
});
|
|
175292
|
+
conn.connect(sshConfig);
|
|
174987
175293
|
});
|
|
174988
|
-
|
|
174989
|
-
clearTimeout(timeout);
|
|
174990
|
-
if (!resolved) {
|
|
174991
|
-
resolved = true;
|
|
174992
|
-
resolve(false);
|
|
174993
|
-
}
|
|
174994
|
-
});
|
|
174995
|
-
conn.connect(sshConfig);
|
|
174996
|
-
});
|
|
175294
|
+
}).catch(() => false);
|
|
174997
175295
|
}
|
|
174998
175296
|
};
|
|
174999
175297
|
|
|
@@ -175362,6 +175660,22 @@ function buildClaudeArgs(options) {
|
|
|
175362
175660
|
if (options.agents && Object.keys(options.agents).length > 0) {
|
|
175363
175661
|
args.push("--agents", JSON.stringify(options.agents));
|
|
175364
175662
|
}
|
|
175663
|
+
if (options.mcpConfig) {
|
|
175664
|
+
if (options.mcpConfig.inlineServers && Object.keys(options.mcpConfig.inlineServers).length > 0) {
|
|
175665
|
+
args.push(
|
|
175666
|
+
"--mcp-config",
|
|
175667
|
+
JSON.stringify({ mcpServers: options.mcpConfig.inlineServers })
|
|
175668
|
+
);
|
|
175669
|
+
}
|
|
175670
|
+
if (options.mcpConfig.configFilePaths && options.mcpConfig.configFilePaths.length > 0) {
|
|
175671
|
+
for (const filePath of options.mcpConfig.configFilePaths) {
|
|
175672
|
+
args.push("--mcp-config", filePath);
|
|
175673
|
+
}
|
|
175674
|
+
}
|
|
175675
|
+
if (options.mcpConfig.strictMode) {
|
|
175676
|
+
args.push("--strict-mcp-config");
|
|
175677
|
+
}
|
|
175678
|
+
}
|
|
175365
175679
|
if (options.additionalArgs && options.additionalArgs.length > 0) {
|
|
175366
175680
|
args.push(...options.additionalArgs);
|
|
175367
175681
|
}
|
|
@@ -175809,6 +176123,8 @@ var ClaudeCode = class {
|
|
|
175809
176123
|
...modelDescription,
|
|
175810
176124
|
// Custom subagents
|
|
175811
176125
|
...agentsDescription,
|
|
176126
|
+
// MCP servers
|
|
176127
|
+
...mcpServersDescription,
|
|
175812
176128
|
// Additional options
|
|
175813
176129
|
...optionsDescription
|
|
175814
176130
|
]
|