Skip to content

Commit 01af89e

Browse files
committed
handle timeout correct in shellStart
1 parent 2630fa5 commit 01af89e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/tools/system/shellStart.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const returnSchema = z.union([
4242
error: z.string().optional(),
4343
})
4444
.describe(
45-
"Synchronous execution results when command completes within timeout",
45+
"Synchronous execution results when command completes within timeout"
4646
),
4747
z
4848
.object({
@@ -58,6 +58,8 @@ const returnSchema = z.union([
5858
type Parameters = z.infer<typeof parameterSchema>;
5959
type ReturnType = z.infer<typeof returnSchema>;
6060

61+
const DEFAULT_TIMEOUT = 100;
62+
6163
export const shellStartTool: Tool<Parameters, ReturnType> = {
6264
name: "shellStart",
6365
description:
@@ -66,8 +68,8 @@ export const shellStartTool: Tool<Parameters, ReturnType> = {
6668
returns: zodToJsonSchema(returnSchema),
6769

6870
execute: async (
69-
{ command, timeout = 100 },
70-
{ logger },
71+
{ command, timeout = DEFAULT_TIMEOUT },
72+
{ logger }
7173
): Promise<ReturnType> => {
7274
logger.verbose(`Starting shell command: ${command}`);
7375

@@ -122,7 +124,7 @@ export const shellStartTool: Tool<Parameters, ReturnType> = {
122124

123125
process.on("exit", (code, signal) => {
124126
logger.verbose(
125-
`[${instanceId}] Process exited with code ${code} and signal ${signal}`,
127+
`[${instanceId}] Process exited with code ${code} and signal ${signal}`
126128
);
127129

128130
processState.state.completed = true;
@@ -170,9 +172,12 @@ export const shellStartTool: Tool<Parameters, ReturnType> = {
170172
});
171173
},
172174

173-
logParameters: (input, { logger }) => {
175+
logParameters: (
176+
{ command, description, timeout = DEFAULT_TIMEOUT },
177+
{ logger }
178+
) => {
174179
logger.info(
175-
`Starting "${input.command}", ${input.description} (timeout: ${input.timeout}ms)`,
180+
`Starting "${command}", ${description} (timeout: ${timeout}ms)`
176181
);
177182
},
178183
logReturns: (output, { logger }) => {

0 commit comments

Comments
 (0)