51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
export function formatToolActivity(toolName: string): string {
|
|
switch (toolName) {
|
|
// Built-in provider tool names
|
|
case "read_file":
|
|
case "Read":
|
|
return "Reading file...";
|
|
case "write_file":
|
|
case "Write":
|
|
case "Edit":
|
|
return "Writing file...";
|
|
case "list_directory":
|
|
case "Glob":
|
|
return "Listing files...";
|
|
case "search_files":
|
|
case "Grep":
|
|
return "Searching files...";
|
|
case "exec_shell":
|
|
case "Bash":
|
|
return "Executing command...";
|
|
// Claude Code additional tool names
|
|
case "Task":
|
|
return "Running task...";
|
|
case "WebFetch":
|
|
return "Fetching web content...";
|
|
case "WebSearch":
|
|
return "Searching the web...";
|
|
case "NotebookEdit":
|
|
return "Editing notebook...";
|
|
case "TodoWrite":
|
|
return "Updating tasks...";
|
|
default:
|
|
return `Using ${toolName}...`;
|
|
}
|
|
}
|
|
|
|
export const estimateTokens = (text: string): number =>
|
|
Math.ceil(text.length / 4);
|
|
|
|
export const getContextWindowSize = (
|
|
modelName: string,
|
|
claudeContextWindows?: Map<string, number>,
|
|
): number => {
|
|
if (modelName.startsWith("claude-")) {
|
|
return claudeContextWindows?.get(modelName) ?? 200000;
|
|
}
|
|
if (modelName.includes("llama3")) return 8192;
|
|
if (modelName.includes("qwen2.5")) return 32768;
|
|
if (modelName.includes("deepseek")) return 16384;
|
|
return 8192;
|
|
};
|