u
This commit is contained in:
@@ -22,6 +22,7 @@ import chalk from 'chalk';
|
||||
import { confirm } from '@inquirer/prompts';
|
||||
import { defineTool, ToolError } from 'llmorbiter';
|
||||
import { ROOT_DIR } from '../config.js';
|
||||
import { emitToolCall, emitToolResult, clip } from './notify.js';
|
||||
|
||||
const DEFAULT_TAIL_LINES = 100; // trailing lines of output returned to the model
|
||||
const DEFAULT_TIMEOUT_MS = 30_000; // 30s hard limit per command
|
||||
@@ -255,3 +256,25 @@ export const bashExecTool = defineTool({
|
||||
return result;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Call notification: the command flattened to one line, plus a custom timeout
|
||||
* when one is set. The approval prompt that follows shows the full command.
|
||||
*/
|
||||
export function notifyCall(args = {}) {
|
||||
const { command, timeout } = args;
|
||||
const oneLine = String(command ?? '').replace(/\s*\n\s*/g, ' ; ');
|
||||
const extras = Number.isInteger(timeout) && timeout !== DEFAULT_TIMEOUT_MS ? ` timeout=${timeout}` : '';
|
||||
emitToolCall(bashExecTool.name, clip(`${oneLine}${extras}`));
|
||||
}
|
||||
|
||||
/**
|
||||
* Result notification: the process exit status (or signal / timeout).
|
||||
*/
|
||||
export function notifyResult(result = {}) {
|
||||
const parts = [];
|
||||
if (result.exitCode !== undefined && result.exitCode !== null) parts.push(`exit ${result.exitCode}`);
|
||||
else if (result.signal) parts.push(`signal ${result.signal}`);
|
||||
if (result.timedOut) parts.push('timed out');
|
||||
emitToolResult(bashExecTool.name, parts.join(' ') || 'done');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user