shell tool tweaks (#194)
This commit is contained in:
parent
a9dc2772dd
commit
a8f679ccb5
|
@ -1,8 +1,11 @@
|
||||||
This is a minimal shell tool that executes a given command as `bash -c <command>`.
|
This tool executes a given shell command as `bash -c <command>`.
|
||||||
Command can be any valid single-line Bash command.
|
Command can be any valid single-line Bash command.
|
||||||
|
Command can start background processes using `&`.
|
||||||
|
|
||||||
The following information is returned:
|
The following information is returned:
|
||||||
|
|
||||||
Command: Given command.
|
Command: Executed command.
|
||||||
|
Directory: Directory (relative to project root) where command was executed, or `(root)`.
|
||||||
Stdout: Output on stdout stream. Can be `(empty)` or partial on error.
|
Stdout: Output on stdout stream. Can be `(empty)` or partial on error.
|
||||||
Stderr: Output on stderr stream. Can be `(empty)` or partial on error.
|
Stderr: Output on stderr stream. Can be `(empty)` or partial on error.
|
||||||
Error: Error or `(none)` if no error occurred.
|
Error: Error or `(none)` if no error occurred.
|
||||||
|
|
|
@ -43,12 +43,14 @@ export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
|
||||||
|
|
||||||
getDescription(params: ShellToolParams): string {
|
getDescription(params: ShellToolParams): string {
|
||||||
let description = `${params.command}`;
|
let description = `${params.command}`;
|
||||||
if (params.description) {
|
// append optional [./directory]
|
||||||
// replace any line breaks with spaces, in case instructions are not followed
|
|
||||||
description += ` (${params.description.replace(/\n/g, ' ')})`;
|
|
||||||
}
|
|
||||||
if (params.directory) {
|
if (params.directory) {
|
||||||
description += ` @ ${params.directory}`;
|
description += ` [./${params.directory}]`;
|
||||||
|
}
|
||||||
|
// append optional (description), replacing any line breaks with spaces
|
||||||
|
// tool description/schema should specify a single line w/o line breaks
|
||||||
|
if (params.description) {
|
||||||
|
description += ` (${params.description.replace(/\n/g, ' ')})`;
|
||||||
}
|
}
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
@ -193,6 +195,7 @@ export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
|
||||||
return {
|
return {
|
||||||
llmContent: [
|
llmContent: [
|
||||||
`Command: ${params.command}`,
|
`Command: ${params.command}`,
|
||||||
|
`Directory: ${params.directory || '(root)'}`,
|
||||||
`Stdout: ${stdout || '(empty)'}`,
|
`Stdout: ${stdout || '(empty)'}`,
|
||||||
`Stderr: ${stderr || '(empty)'}`,
|
`Stderr: ${stderr || '(empty)'}`,
|
||||||
`Error: ${error ?? '(none)'}`,
|
`Error: ${error ?? '(none)'}`,
|
||||||
|
|
Loading…
Reference in New Issue