mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 23:01:30 +00:00
Add abort signal handling to read, write, and edit tools
All tools now check the abort signal before executing and throw "Operation aborted" error if the signal is already aborted. This ensures consistent abort behavior across all tools.
This commit is contained in:
parent
001beff394
commit
e6b47799a4
4 changed files with 84 additions and 2 deletions
|
|
@ -26,7 +26,12 @@ export const readTool: AgentTool<typeof readSchema> = {
|
|||
label: "read",
|
||||
description: "Read the contents of a file. Returns the full file content as text.",
|
||||
parameters: readSchema,
|
||||
execute: async (_toolCallId: string, { path }: { path: string }) => {
|
||||
execute: async (_toolCallId: string, { path }: { path: string }, signal?: AbortSignal) => {
|
||||
// Check if already aborted
|
||||
if (signal?.aborted) {
|
||||
throw new Error("Operation aborted");
|
||||
}
|
||||
|
||||
const absolutePath = resolve(expandPath(path));
|
||||
|
||||
if (!existsSync(absolutePath)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue