centaurus-cli 2.8.4 → 2.8.5
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/cli-adapter.d.ts +7 -0
- package/dist/cli-adapter.d.ts.map +1 -1
- package/dist/cli-adapter.js +143 -35
- package/dist/cli-adapter.js.map +1 -1
- package/dist/config/models.d.ts.map +1 -1
- package/dist/config/models.js +14 -4
- package/dist/config/models.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/components/App.d.ts +2 -0
- package/dist/ui/components/App.d.ts.map +1 -1
- package/dist/ui/components/App.js +67 -4
- package/dist/ui/components/App.js.map +1 -1
- package/dist/ui/components/ConnectionStatusMessage.d.ts +17 -0
- package/dist/ui/components/ConnectionStatusMessage.d.ts.map +1 -0
- package/dist/ui/components/ConnectionStatusMessage.js +66 -0
- package/dist/ui/components/ConnectionStatusMessage.js.map +1 -0
- package/dist/ui/components/InteractiveShell.d.ts +2 -0
- package/dist/ui/components/InteractiveShell.d.ts.map +1 -1
- package/dist/ui/components/InteractiveShell.js +11 -2
- package/dist/ui/components/InteractiveShell.js.map +1 -1
- package/dist/ui/components/MessageDisplay.d.ts.map +1 -1
- package/dist/ui/components/MessageDisplay.js +5 -0
- package/dist/ui/components/MessageDisplay.js.map +1 -1
- package/dist/ui/components/ToolExecutionMessage.d.ts.map +1 -1
- package/dist/ui/components/ToolExecutionMessage.js +40 -24
- package/dist/ui/components/ToolExecutionMessage.js.map +1 -1
- package/dist/utils/editor-utils.d.ts +3 -3
- package/dist/utils/editor-utils.d.ts.map +1 -1
- package/dist/utils/editor-utils.js +25 -18
- package/dist/utils/editor-utils.js.map +1 -1
- package/dist/utils/terminal-output.d.ts.map +1 -1
- package/dist/utils/terminal-output.js +55 -1
- package/dist/utils/terminal-output.js.map +1 -1
- package/models-config.json +24 -4
- package/package.json +1 -1
package/dist/cli-adapter.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export declare class CentaurusCLI {
|
|
|
37
37
|
private requestIntentionallyAborted;
|
|
38
38
|
private mcpCommandHandler?;
|
|
39
39
|
private onInteractiveEditorMode?;
|
|
40
|
+
private onConnectionStatusUpdate?;
|
|
40
41
|
constructor();
|
|
41
42
|
setOnResponseCallback(callback: (message: string) => void): void;
|
|
42
43
|
setOnDirectMessageCallback(callback: (message: string) => void): void;
|
|
@@ -85,6 +86,12 @@ export declare class CentaurusCLI {
|
|
|
85
86
|
setOnSubshellContextChange(callback: (context: SubshellContext) => void): void;
|
|
86
87
|
setOnPasswordRequest(callback: (message: string) => Promise<string>): void;
|
|
87
88
|
setOnInteractiveEditorMode(callback: (active: boolean, command?: string, cwd?: string, remoteContext?: SubshellContext) => void): void;
|
|
89
|
+
setOnConnectionStatusUpdate(callback: (status: {
|
|
90
|
+
type: 'ssh' | 'wsl' | 'docker';
|
|
91
|
+
status: 'connecting' | 'connected' | 'error';
|
|
92
|
+
connectionString?: string;
|
|
93
|
+
error?: string;
|
|
94
|
+
}) => void): void;
|
|
88
95
|
private initializeMCP;
|
|
89
96
|
writeToShellStdin(input: string): void;
|
|
90
97
|
sendSignalToShell(signal: NodeJS.Signals): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-adapter.d.ts","sourceRoot":"","sources":["../src/cli-adapter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAY/C,OAAO,EAA8H,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAalL,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AASrD,qBAAa,YAAY;IACvB,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,mBAAmB,CAAmB;IAC9C,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,QAAQ,CAAkB;IACl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AUhB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA0CjC;;;OAGG;IACH,mBAAmB,IAAI,MAAM,GAAG,IAAI;IAkCpC;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;OAEG;YACW,yBAAyB;IAsBvC;;OAEG;YACW,oBAAoB;IAmBlC,QAAQ,IAAI,MAAM;IAMlB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAQ5B;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAuC1B,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAgiCrC,kBAAkB;IA0dhC;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAe7B;;;OAGG;IACH,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,uBAAuB;IAsC/B;;OAEG;IACH,iBAAiB,IAAI,IAAI;IA6BzB;;;OAGG;IACH,4BAA4B,CAAC,OAAO,EAAE,UAAU,CAAC,kBAAkB,GAAG,SAAS,GAAG,IAAI;IAItF;;OAEG;YACW,0BAA0B;CA8ZzC"}
|
package/dist/cli-adapter.js
CHANGED
|
@@ -68,6 +68,7 @@ export class CentaurusCLI {
|
|
|
68
68
|
requestIntentionallyAborted = false;
|
|
69
69
|
mcpCommandHandler;
|
|
70
70
|
onInteractiveEditorMode;
|
|
71
|
+
onConnectionStatusUpdate;
|
|
71
72
|
constructor() {
|
|
72
73
|
this.configManager = new ConfigManager();
|
|
73
74
|
this.toolRegistry = new ToolRegistry();
|
|
@@ -150,6 +151,9 @@ export class CentaurusCLI {
|
|
|
150
151
|
setOnInteractiveEditorMode(callback) {
|
|
151
152
|
this.onInteractiveEditorMode = callback;
|
|
152
153
|
}
|
|
154
|
+
setOnConnectionStatusUpdate(callback) {
|
|
155
|
+
this.onConnectionStatusUpdate = callback;
|
|
156
|
+
}
|
|
153
157
|
async initializeMCP() {
|
|
154
158
|
try {
|
|
155
159
|
const mcpConfigManager = new MCPConfigManager();
|
|
@@ -241,10 +245,39 @@ export class CentaurusCLI {
|
|
|
241
245
|
*/
|
|
242
246
|
notifyToolStatus(toolName, status, args, result, error) {
|
|
243
247
|
if (this.onToolExecutionUpdate) {
|
|
244
|
-
//
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
+
// Get current context for remote prefix
|
|
249
|
+
const currentContext = this.contextManager.getCurrentContext();
|
|
250
|
+
// Build remote context prefix for SSH/Docker/WSL
|
|
251
|
+
let remoteContext;
|
|
252
|
+
if (currentContext.type !== 'local') {
|
|
253
|
+
const metadata = currentContext.metadata;
|
|
254
|
+
if (currentContext.type === 'ssh' && metadata) {
|
|
255
|
+
// SSH: user@hostname
|
|
256
|
+
const username = metadata.username || 'user';
|
|
257
|
+
const hostname = metadata.hostname || 'remote';
|
|
258
|
+
remoteContext = `${username}@${hostname}`;
|
|
259
|
+
}
|
|
260
|
+
else if (currentContext.type === 'wsl' && metadata) {
|
|
261
|
+
// WSL: distroName or just wsl
|
|
262
|
+
remoteContext = `wsl:${metadata.distroName || 'wsl'}`;
|
|
263
|
+
}
|
|
264
|
+
else if (currentContext.type === 'docker' && metadata) {
|
|
265
|
+
// Docker: container id (first 12 chars)
|
|
266
|
+
remoteContext = `docker:${metadata.containerId?.substring(0, 12) || 'container'}`;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// Add cwd and remoteContext to arguments for execute_command tool
|
|
270
|
+
let toolArgs = args;
|
|
271
|
+
if (toolName === 'execute_command' && args) {
|
|
272
|
+
toolArgs = { ...args, cwd: this.cwd, remoteContext };
|
|
273
|
+
}
|
|
274
|
+
else if (remoteContext && args) {
|
|
275
|
+
// For other tools, also add remoteContext if in remote environment
|
|
276
|
+
toolArgs = { ...args, remoteContext };
|
|
277
|
+
}
|
|
278
|
+
else if (remoteContext) {
|
|
279
|
+
toolArgs = { remoteContext };
|
|
280
|
+
}
|
|
248
281
|
this.onToolExecutionUpdate({
|
|
249
282
|
toolName,
|
|
250
283
|
status,
|
|
@@ -922,12 +955,26 @@ Press Enter to continue...
|
|
|
922
955
|
const effectiveCwd = currentCtx.type !== 'local'
|
|
923
956
|
? currentCtx.metadata?.workingDirectory || '~'
|
|
924
957
|
: this.cwd;
|
|
958
|
+
// Build remote context prefix for SSH/Docker/WSL (for path display in UI)
|
|
959
|
+
let remoteContext;
|
|
960
|
+
if (currentCtx.type !== 'local') {
|
|
961
|
+
const metadata = currentCtx.metadata;
|
|
962
|
+
if (currentCtx.type === 'ssh' && metadata) {
|
|
963
|
+
remoteContext = `${metadata.username || 'user'}@${metadata.hostname || 'remote'}`;
|
|
964
|
+
}
|
|
965
|
+
else if (currentCtx.type === 'wsl' && metadata) {
|
|
966
|
+
remoteContext = `wsl:${metadata.distroName || 'wsl'}`;
|
|
967
|
+
}
|
|
968
|
+
else if (currentCtx.type === 'docker' && metadata) {
|
|
969
|
+
remoteContext = `docker:${metadata.containerId?.substring(0, 12) || 'container'}`;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
925
972
|
// Notify UI: tool is executing (send before execution starts)
|
|
926
973
|
if (this.onToolExecutionUpdate) {
|
|
927
|
-
// Add cwd to arguments for execute_command tool
|
|
974
|
+
// Add cwd to arguments for execute_command tool, and remoteContext for all tools
|
|
928
975
|
const toolArgs = toolCall.name === 'execute_command'
|
|
929
|
-
? { ...toolCall.arguments, cwd: effectiveCwd }
|
|
930
|
-
: toolCall.arguments;
|
|
976
|
+
? { ...toolCall.arguments, cwd: effectiveCwd, remoteContext }
|
|
977
|
+
: { ...toolCall.arguments, remoteContext };
|
|
931
978
|
this.onToolExecutionUpdate({
|
|
932
979
|
toolName: toolCall.name,
|
|
933
980
|
status: 'executing',
|
|
@@ -943,10 +990,10 @@ Press Enter to continue...
|
|
|
943
990
|
conversationLogger.logToolResult(toolCall.name, toolCall.id, result.result, true);
|
|
944
991
|
// Notify UI: tool succeeded (send full result to UI)
|
|
945
992
|
if (this.onToolExecutionUpdate) {
|
|
946
|
-
// Add cwd to arguments for execute_command tool
|
|
993
|
+
// Add cwd to arguments for execute_command tool, and remoteContext for all tools
|
|
947
994
|
const toolArgs = toolCall.name === 'execute_command'
|
|
948
|
-
? { ...toolCall.arguments, cwd: effectiveCwd }
|
|
949
|
-
: toolCall.arguments;
|
|
995
|
+
? { ...toolCall.arguments, cwd: effectiveCwd, remoteContext }
|
|
996
|
+
: { ...toolCall.arguments, remoteContext };
|
|
950
997
|
this.onToolExecutionUpdate({
|
|
951
998
|
toolName: toolCall.name,
|
|
952
999
|
status: 'completed',
|
|
@@ -982,10 +1029,10 @@ Press Enter to continue...
|
|
|
982
1029
|
}
|
|
983
1030
|
// Notify UI: tool failed
|
|
984
1031
|
if (this.onToolExecutionUpdate) {
|
|
985
|
-
// Add cwd to arguments for execute_command tool
|
|
1032
|
+
// Add cwd to arguments for execute_command tool, and remoteContext for all tools
|
|
986
1033
|
const toolArgs = toolCall.name === 'execute_command'
|
|
987
|
-
? { ...toolCall.arguments, cwd: effectiveCwd }
|
|
988
|
-
: toolCall.arguments;
|
|
1034
|
+
? { ...toolCall.arguments, cwd: effectiveCwd, remoteContext }
|
|
1035
|
+
: { ...toolCall.arguments, remoteContext };
|
|
989
1036
|
this.onToolExecutionUpdate({
|
|
990
1037
|
toolName: toolCall.name,
|
|
991
1038
|
status: 'error',
|
|
@@ -1011,12 +1058,27 @@ Press Enter to continue...
|
|
|
1011
1058
|
if (error.message && error.message.includes('Operation cancelled by user')) {
|
|
1012
1059
|
userCancelledOperation = true;
|
|
1013
1060
|
}
|
|
1061
|
+
// Build remote context for error notification
|
|
1062
|
+
const catchCtx = this.contextManager.getCurrentContext();
|
|
1063
|
+
let catchRemoteContext;
|
|
1064
|
+
if (catchCtx.type !== 'local') {
|
|
1065
|
+
const metadata = catchCtx.metadata;
|
|
1066
|
+
if (catchCtx.type === 'ssh' && metadata) {
|
|
1067
|
+
catchRemoteContext = `${metadata.username || 'user'}@${metadata.hostname || 'remote'}`;
|
|
1068
|
+
}
|
|
1069
|
+
else if (catchCtx.type === 'wsl' && metadata) {
|
|
1070
|
+
catchRemoteContext = `wsl:${metadata.distroName || 'wsl'}`;
|
|
1071
|
+
}
|
|
1072
|
+
else if (catchCtx.type === 'docker' && metadata) {
|
|
1073
|
+
catchRemoteContext = `docker:${metadata.containerId?.substring(0, 12) || 'container'}`;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1014
1076
|
// Notify UI: tool failed
|
|
1015
1077
|
if (this.onToolExecutionUpdate) {
|
|
1016
|
-
// Add cwd to arguments for execute_command tool
|
|
1078
|
+
// Add cwd to arguments for execute_command tool, and remoteContext for all tools
|
|
1017
1079
|
const toolArgs = toolCall.name === 'execute_command'
|
|
1018
|
-
? { ...toolCall.arguments, cwd: this.cwd }
|
|
1019
|
-
: toolCall.arguments;
|
|
1080
|
+
? { ...toolCall.arguments, cwd: this.cwd, remoteContext: catchRemoteContext }
|
|
1081
|
+
: { ...toolCall.arguments, remoteContext: catchRemoteContext };
|
|
1020
1082
|
this.onToolExecutionUpdate({
|
|
1021
1083
|
toolName: toolCall.name,
|
|
1022
1084
|
status: 'error',
|
|
@@ -1913,9 +1975,34 @@ Once the user approves the plan:
|
|
|
1913
1975
|
// Detect subshell commands
|
|
1914
1976
|
const detection = this.commandDetector.detect(command);
|
|
1915
1977
|
if (detection) {
|
|
1916
|
-
//
|
|
1917
|
-
|
|
1918
|
-
|
|
1978
|
+
// Build connection string for display (e.g., "rohan@localhost" for SSH)
|
|
1979
|
+
let connectionString = '';
|
|
1980
|
+
if (detection.handler.type === 'ssh') {
|
|
1981
|
+
// Parse SSH command to get user@host
|
|
1982
|
+
const sshMatch = command.match(/ssh\s+(?:(?:-\w+\s+)+)?(?:(\S+)@)?(\S+)/);
|
|
1983
|
+
if (sshMatch) {
|
|
1984
|
+
const user = sshMatch[1] || 'user';
|
|
1985
|
+
const host = sshMatch[2] || 'remote';
|
|
1986
|
+
connectionString = `${user}@${host}`;
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
else if (detection.handler.type === 'wsl') {
|
|
1990
|
+
// Parse WSL command to get distribution name
|
|
1991
|
+
const wslMatch = command.match(/wsl(?:\s+(?:-d|--distribution)\s+(\S+))?/);
|
|
1992
|
+
connectionString = wslMatch?.[1] || 'Ubuntu';
|
|
1993
|
+
}
|
|
1994
|
+
else if (detection.handler.type === 'docker') {
|
|
1995
|
+
// Parse Docker command to get container
|
|
1996
|
+
const dockerMatch = command.match(/docker\s+exec\s+(?:(?:-\w+\s+)+)?(\S+)/);
|
|
1997
|
+
connectionString = dockerMatch?.[1]?.substring(0, 12) || 'container';
|
|
1998
|
+
}
|
|
1999
|
+
// Show connecting message with spinner (dynamic)
|
|
2000
|
+
if (this.onConnectionStatusUpdate) {
|
|
2001
|
+
this.onConnectionStatusUpdate({
|
|
2002
|
+
type: detection.handler.type,
|
|
2003
|
+
status: 'connecting',
|
|
2004
|
+
connectionString
|
|
2005
|
+
});
|
|
1919
2006
|
}
|
|
1920
2007
|
// Update connection state
|
|
1921
2008
|
this.contextManager.updateConnectionState('connecting');
|
|
@@ -1923,19 +2010,26 @@ Once the user approves the plan:
|
|
|
1923
2010
|
// Connect to subshell
|
|
1924
2011
|
const context = await detection.handler.connect(command, this.cwd);
|
|
1925
2012
|
this.contextManager.pushContext(context);
|
|
1926
|
-
// Show success message
|
|
1927
|
-
if (this.
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
2013
|
+
// Show success message (replaces the spinner with static message)
|
|
2014
|
+
if (this.onConnectionStatusUpdate) {
|
|
2015
|
+
this.onConnectionStatusUpdate({
|
|
2016
|
+
type: detection.handler.type,
|
|
2017
|
+
status: 'connected',
|
|
2018
|
+
connectionString
|
|
2019
|
+
});
|
|
1931
2020
|
}
|
|
1932
2021
|
return;
|
|
1933
2022
|
}
|
|
1934
2023
|
catch (error) {
|
|
1935
2024
|
// Connection failed
|
|
1936
2025
|
this.contextManager.updateConnectionState('error');
|
|
1937
|
-
if (this.
|
|
1938
|
-
this.
|
|
2026
|
+
if (this.onConnectionStatusUpdate) {
|
|
2027
|
+
this.onConnectionStatusUpdate({
|
|
2028
|
+
type: detection.handler.type,
|
|
2029
|
+
status: 'error',
|
|
2030
|
+
connectionString,
|
|
2031
|
+
error: error.message
|
|
2032
|
+
});
|
|
1939
2033
|
}
|
|
1940
2034
|
return;
|
|
1941
2035
|
}
|
|
@@ -1987,12 +2081,26 @@ Once the user approves the plan:
|
|
|
1987
2081
|
const effectiveCwd = currentContext.type !== 'local'
|
|
1988
2082
|
? currentContext.metadata?.workingDirectory || '~'
|
|
1989
2083
|
: this.cwd;
|
|
2084
|
+
// Build remote context prefix for SSH/Docker/WSL (for path display in UI)
|
|
2085
|
+
let remoteContext;
|
|
2086
|
+
if (currentContext.type !== 'local') {
|
|
2087
|
+
const metadata = currentContext.metadata;
|
|
2088
|
+
if (currentContext.type === 'ssh' && metadata) {
|
|
2089
|
+
remoteContext = `${metadata.username || 'user'}@${metadata.hostname || 'remote'}`;
|
|
2090
|
+
}
|
|
2091
|
+
else if (currentContext.type === 'wsl' && metadata) {
|
|
2092
|
+
remoteContext = `wsl:${metadata.distroName || 'wsl'}`;
|
|
2093
|
+
}
|
|
2094
|
+
else if (currentContext.type === 'docker' && metadata) {
|
|
2095
|
+
remoteContext = `docker:${metadata.containerId?.substring(0, 12) || 'container'}`;
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
1990
2098
|
// Notify UI that command is executing
|
|
1991
2099
|
if (this.onToolExecutionUpdate) {
|
|
1992
2100
|
this.onToolExecutionUpdate({
|
|
1993
2101
|
toolName: 'execute_command',
|
|
1994
2102
|
status: 'executing',
|
|
1995
|
-
arguments: { command, cwd: effectiveCwd, isPty: shellUtils.isPtyAvailable() }
|
|
2103
|
+
arguments: { command, cwd: effectiveCwd, isPty: shellUtils.isPtyAvailable(), remoteContext }
|
|
1996
2104
|
});
|
|
1997
2105
|
}
|
|
1998
2106
|
// Execute with streaming support for local commands
|
|
@@ -2015,7 +2123,7 @@ Once the user approves the plan:
|
|
|
2015
2123
|
status: 'error',
|
|
2016
2124
|
result: output,
|
|
2017
2125
|
error: `Exit Code: ${exitCode}`,
|
|
2018
|
-
arguments: { command, cwd: this.cwd }
|
|
2126
|
+
arguments: { command, cwd: this.cwd, remoteContext }
|
|
2019
2127
|
});
|
|
2020
2128
|
}
|
|
2021
2129
|
else {
|
|
@@ -2023,7 +2131,7 @@ Once the user approves the plan:
|
|
|
2023
2131
|
toolName: 'execute_command',
|
|
2024
2132
|
status: 'completed',
|
|
2025
2133
|
result: output || 'Command executed successfully',
|
|
2026
|
-
arguments: { command, cwd: this.cwd }
|
|
2134
|
+
arguments: { command, cwd: this.cwd, remoteContext }
|
|
2027
2135
|
});
|
|
2028
2136
|
}
|
|
2029
2137
|
}
|
|
@@ -2053,7 +2161,7 @@ Once the user approves the plan:
|
|
|
2053
2161
|
status: 'error',
|
|
2054
2162
|
result: output,
|
|
2055
2163
|
error: `Exit Code: ${exitCode}`,
|
|
2056
|
-
arguments: { command, cwd: remoteCwd }
|
|
2164
|
+
arguments: { command, cwd: remoteCwd, remoteContext }
|
|
2057
2165
|
});
|
|
2058
2166
|
}
|
|
2059
2167
|
else {
|
|
@@ -2061,7 +2169,7 @@ Once the user approves the plan:
|
|
|
2061
2169
|
toolName: 'execute_command',
|
|
2062
2170
|
status: 'completed',
|
|
2063
2171
|
result: output || 'Command executed successfully',
|
|
2064
|
-
arguments: { command, cwd: remoteCwd }
|
|
2172
|
+
arguments: { command, cwd: remoteCwd, remoteContext }
|
|
2065
2173
|
});
|
|
2066
2174
|
}
|
|
2067
2175
|
}
|
|
@@ -2104,7 +2212,7 @@ Once the user approves the plan:
|
|
|
2104
2212
|
status: 'error',
|
|
2105
2213
|
result: output,
|
|
2106
2214
|
error: `Exit Code: ${exitCode}`,
|
|
2107
|
-
arguments: { command, cwd: remoteCwd }
|
|
2215
|
+
arguments: { command, cwd: remoteCwd, remoteContext }
|
|
2108
2216
|
});
|
|
2109
2217
|
}
|
|
2110
2218
|
else {
|
|
@@ -2112,7 +2220,7 @@ Once the user approves the plan:
|
|
|
2112
2220
|
toolName: 'execute_command',
|
|
2113
2221
|
status: 'completed',
|
|
2114
2222
|
result: output || 'Command executed successfully',
|
|
2115
|
-
arguments: { command, cwd: remoteCwd }
|
|
2223
|
+
arguments: { command, cwd: remoteCwd, remoteContext }
|
|
2116
2224
|
});
|
|
2117
2225
|
}
|
|
2118
2226
|
}
|
|
@@ -2158,7 +2266,7 @@ Once the user approves the plan:
|
|
|
2158
2266
|
status: 'error',
|
|
2159
2267
|
result: output,
|
|
2160
2268
|
error: `Exit Code: ${exitCode}`,
|
|
2161
|
-
arguments: { command, cwd: remoteCwd }
|
|
2269
|
+
arguments: { command, cwd: remoteCwd, remoteContext }
|
|
2162
2270
|
});
|
|
2163
2271
|
}
|
|
2164
2272
|
else {
|
|
@@ -2166,7 +2274,7 @@ Once the user approves the plan:
|
|
|
2166
2274
|
toolName: 'execute_command',
|
|
2167
2275
|
status: 'completed',
|
|
2168
2276
|
result: output || 'Command executed successfully',
|
|
2169
|
-
arguments: { command, cwd: remoteCwd }
|
|
2277
|
+
arguments: { command, cwd: remoteCwd, remoteContext }
|
|
2170
2278
|
});
|
|
2171
2279
|
}
|
|
2172
2280
|
}
|