feat(ollama): add tool calling support

Add Ollama tool integration for web search, weather, datetime, filesystem operations, and shell evaluation. Implement multi-round tool call handling, streaming updates, thinking cleanup, and safer path validation for file tools.

Also add related environment configuration, command execution helper, MarkdownV2 cancel handling fixes, and remove unused TryAgain callback command.
This commit is contained in:
2026-05-03 15:16:14 +03:00
parent 86b26813e2
commit 2fc60806ff
7 changed files with 2046 additions and 129 deletions
+25 -5
View File
@@ -7,6 +7,8 @@ import {Requirement} from "../base/requirement";
export class Ae extends Command {
argsMode = "required" as const;
command = ["ae"];
title = "/ae";
description = "evaluation";
@@ -16,11 +18,8 @@ export class Ae extends Command {
const match = params?.[3] || "";
try {
let e = eval(match);
e = ((typeof e == "string") ? e : JSON.stringify(e));
await oldSendMessage(msg, e).catch(async () => await errorPlaceholder(msg));
let result = this.executeEvaluation(match);
await oldSendMessage(msg, result).catch(async () => await errorPlaceholder(msg));
} catch (e: any) {
const text = e.message.toString();
@@ -35,4 +34,25 @@ export class Ae extends Command {
await oldSendMessage(msg, text).catch(logError);
}
}
executeEvaluation(evaluation: string): string {
try {
let e = eval(evaluation);
e = ((typeof e == "string") ? e : JSON.stringify(e));
return e;
} catch (e: any) {
const text = e.message.toString();
if (text.includes("is not defined")) {
return "Variable not defined";
}
logError(`${text}
* Stacktrace: ${e.stack}`);
return text;
}
}
}
File diff suppressed because it is too large Load Diff