summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/shell.ts
diff options
context:
space:
mode:
authorOlcan <[email protected]>2025-06-02 14:50:12 -0700
committerGitHub <[email protected]>2025-06-02 14:50:12 -0700
commit1dcf0a4cbdee249fd9a20c67b9b718563353773b (patch)
treed858433eafd111282f4f3e3c730dcfe350cf7d37 /packages/core/src/tools/shell.ts
parent51949f3121dd924002974a4e50f5ee34fd14c3ef (diff)
strip ansi from shell output (#699)
Diffstat (limited to 'packages/core/src/tools/shell.ts')
-rw-r--r--packages/core/src/tools/shell.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts
index d0cad218..53e2bbf3 100644
--- a/packages/core/src/tools/shell.ts
+++ b/packages/core/src/tools/shell.ts
@@ -18,6 +18,8 @@ import {
} from './tools.js';
import { SchemaValidator } from '../utils/schemaValidator.js';
import { getErrorMessage } from '../utils/errors.js';
+import stripAnsi from 'strip-ansi';
+
export interface ShellToolParams {
command: string;
description?: string;
@@ -177,7 +179,7 @@ export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
// removing listeners can overflow OS buffer and block subprocesses
// destroying (e.g. shell.stdout.destroy()) can terminate subprocesses via SIGPIPE
if (!exited) {
- const str = data.toString();
+ const str = stripAnsi(data.toString());
stdout += str;
appendOutput(str);
}
@@ -186,7 +188,7 @@ export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
let stderr = '';
shell.stderr.on('data', (data: Buffer) => {
if (!exited) {
- const str = data.toString();
+ const str = stripAnsi(data.toString());
stderr += str;
appendOutput(str);
}