Remove terminal tool and dependencies.

- We now solely use the shell tool. This deletes all content around the legacy terminal tool so we can focus on improving the new Shell tool.
- Remove instances from sandboxing, tests, utilities etc.
This commit is contained in:
Taylor Mullen
2025-05-11 12:34:41 -07:00
committed by N. Taylor Mullen
parent dcb67c32a5
commit cf91f72c5c
7 changed files with 2 additions and 1552 deletions

View File

@@ -90,101 +90,6 @@ const findEnclosingCodeBlockStart = (
return -1;
};
export const findSafeSplitPoint = (
content: string,
idealMaxLength: number = 500,
): number => {
if (content.length <= idealMaxLength) {
return content.length;
}
const enclosingBlockStartForIdealMax = findEnclosingCodeBlockStart(
content,
idealMaxLength,
);
if (enclosingBlockStartForIdealMax !== -1) {
// idealMaxLength is inside a code block. Try to split *before* this block.
const textToSearchForNewline = content.substring(
0,
enclosingBlockStartForIdealMax,
);
// Iteratively search for the last safe \n\n before enclosingBlockStartForIdealMax
let currentSearchFromIndex = textToSearchForNewline.length;
while (currentSearchFromIndex > 0) {
// searchEndIndex refers to character count to search within
const dnlIndex = textToSearchForNewline.lastIndexOf(
'\n\n',
currentSearchFromIndex - 1,
); // fromIndex for lastIndexOf is 0-based
if (dnlIndex === -1) break;
const potentialSplit = dnlIndex + 2;
// The split must be strictly before the block idealMaxLength was in.
// This is implicitly true if dnlIndex is found within textToSearchForNewline.
if (!isIndexInsideCodeBlock(content, potentialSplit)) {
// Condition: (potentialSplit > 0) OR (it's 0 AND the problematic block also started at 0)
if (
potentialSplit > 0 ||
(enclosingBlockStartForIdealMax === 0 && potentialSplit === 0)
) {
return potentialSplit;
}
}
currentSearchFromIndex = dnlIndex; // Continue search before the start of this found \n\n
// (dnlIndex is start of \n\n, so next search is before it)
}
// Iteratively search for the last safe \n
currentSearchFromIndex = textToSearchForNewline.length;
while (currentSearchFromIndex >= 0) {
// Can be 0 if textToSearchForNewline has length 1 and it's \n
const snlIndex = textToSearchForNewline.lastIndexOf(
'\n',
currentSearchFromIndex - 1,
);
if (snlIndex === -1) break;
const potentialSplit = snlIndex + 1;
if (!isIndexInsideCodeBlock(content, potentialSplit)) {
if (
potentialSplit > 0 ||
(enclosingBlockStartForIdealMax === 0 && potentialSplit === 0)
) {
return potentialSplit;
}
}
currentSearchFromIndex = snlIndex;
}
// Fallback: split right before this code block
return enclosingBlockStartForIdealMax;
}
// idealMaxLength is NOT inside a code block.
// Search forwards from idealMaxLength for the next double newline (\n\n) not in a code block.
let searchStartIndex = idealMaxLength;
while (searchStartIndex < content.length) {
const dnlIndex = content.indexOf('\n\n', searchStartIndex);
if (dnlIndex === -1) {
// No more double newlines found after idealMaxLength
break;
}
const potentialSplitPoint = dnlIndex + 2;
if (!isIndexInsideCodeBlock(content, potentialSplitPoint)) {
return potentialSplitPoint;
}
searchStartIndex = potentialSplitPoint; // Continue search after the found \n\n
}
// If no safe double newline found after idealMaxLength, return content.length
// to keep the entire content as one piece.
return content.length;
};
export const findLastSafeSplitPoint = (content: string) => {
const enclosingBlockStart = findEnclosingCodeBlockStart(
content,