Skip to content

Commit bc3e2f9

Browse files
author
linyuan.yang
committed
fix error
1 parent 43e41f3 commit bc3e2f9

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

‎packages/scorpio.ai/src/Tools/Process/codeTool.ts‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,12 @@ function normalizeStdin(stdin: unknown): string | undefined {
2929
}
3030

3131
function withExecutionMode<T extends z.ZodRawShape>(base: z.ZodObject<T>) {
32-
return z.discriminatedUnion('mode', [
33-
base.extend({
34-
mode: z.literal(CodeToolMode.Sync).describe('Run synchronously and return the final output in this tool call'),
35-
timeout: z.number().optional().default(60000).describe('Timeout in milliseconds, default 60000 (60 s)'),
36-
}),
37-
base.extend({
38-
mode: z.literal(CodeToolMode.Background).describe('Run in the background and use read_process for later output'),
39-
yieldMs: z.number().optional().default(1000).describe('How long to wait for immediate completion before returning a processId, default 1000 ms'),
40-
interactive: z.boolean().optional().default(false).describe('Keep stdin open so write_process can send more input later. Use only for programs that prompt for stdin; this is pipe-based, not a full TTY.'),
41-
}),
42-
]);
32+
return base.extend({
33+
mode: z.enum(CodeToolMode).describe('sync = run synchronously and return final output; background = start a process and use read_process for later output'),
34+
timeout: z.number().optional().describe('For mode=sync: timeout in milliseconds, default 60000 (60 s)'),
35+
yieldMs: z.number().optional().describe('For mode=background: how long to wait for immediate completion before returning a processId, default 1000 ms'),
36+
interactive: z.boolean().optional().describe('For mode=background: keep stdin open so write_process can send more input later. Use only for programs that prompt for stdin; this is pipe-based, not a full TTY.'),
37+
});
4338
}
4439

4540
const shellCodeBaseSchema = z.object({
@@ -59,13 +54,13 @@ export const scriptCodeSchema = withExecutionMode(scriptCodeBaseSchema);
5954

6055
export const readProcessToolSchema = z.object({
6156
processId: z.number().int().positive().describe('The numeric processId returned by shell/script mode="background"'),
62-
yieldMs: z.number().optional().default(1000).describe('How long to wait for new output, default 1000 ms'),
57+
yieldMs: z.number().optional().describe('How long to wait for new output, default 1000 ms'),
6358
});
6459

6560
export const writeProcessToolSchema = z.object({
6661
processId: z.number().int().positive().describe('The numeric processId returned by shell/script mode="background" with interactive=true'),
6762
stdin: z.any().optional().describe('Data to write to the background process stdin. Prefer a string and include a trailing newline for line prompts; objects/arrays are auto-serialized to JSON.'),
68-
close: z.boolean().optional().default(false).describe('Whether to close stdin after writing. Use true when the process needs EOF to continue or finish.'),
63+
close: z.boolean().optional().describe('Whether to close stdin after writing. Use true when the process needs EOF to continue or finish.'),
6964
});
7065

7166
type ShellToolInput = z.infer<typeof shellToolSchema>;

0 commit comments

Comments
 (0)