This commit is contained in:
seb
2026-09-22 20:59:58 +02:00
parent 96d2b80b6c
commit ab2f953e06
23 changed files with 1678 additions and 65 deletions

View File

@@ -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');
}