MCPcopy Create free account
hub / github.com/altic-dev/Pilot / executeCommand

Function executeCommand

src/tools/experiment-code-update.ts:55–136  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

53
54 // Create command executor for bash tool
55 const executeCommand = async (command: string) => {
56 logger.info("Docker bash tool executing command", { sessionId, command });
57
58 const allowedCommands = [
59 "ls",
60 "cat",
61 "find",
62 "git",
63 "mkdir",
64 "cd",
65 "npm",
66 "pnpm",
67 "gh",
68 ];
69 const forbiddenGitConfigPatterns = [
70 "git config user.email",
71 "git config --global user.email",
72 "git config user.name",
73 "git config --global user.name",
74 ];
75 const baseCommand = command.trim().split(/\s+/)[0];
76
77 if (!allowedCommands.includes(baseCommand)) {
78 const errorMsg = `Command '${baseCommand}' is not allowed. Only ${allowedCommands.join(", ")} are permitted.`;
79 logger.error("Docker bash tool command not allowed", {
80 sessionId,
81 command,
82 baseCommand,
83 allowedCommands,
84 });
85 throw new Error(errorMsg);
86 }
87
88 if (
89 forbiddenGitConfigPatterns.some((pattern) => command.includes(pattern))
90 ) {
91 const errorMsg =
92 "Commands that modify git user.name or user.email are forbidden. Use the existing repository configuration.";
93 logger.error("Docker bash tool command forbidden", {
94 sessionId,
95 command,
96 forbiddenPatterns: forbiddenGitConfigPatterns,
97 });
98 throw new Error(errorMsg);
99 }
100
101 try {
102 const { stdout, stderr, exitCode } = await docker.execCommand(sessionId, [
103 "/bin/sh",
104 "-c",
105 command,
106 ]);
107
108 const output = stdout || stderr;
109 logger.info("Docker bash tool command completed", {
110 sessionId,
111 command,
112 exitCode,

Callers 2

createDockerToolsFunction · 0.85
createGenericBashToolFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected