Tool factories

This commit is contained in:
Colin McDonnell
2025-12-15 23:04:20 -08:00
parent 0fced1dfa6
commit 26336d0ac2
21 changed files with 14461 additions and 15875 deletions
+7 -28
View File
@@ -1,7 +1,6 @@
import { type } from "arktype";
import { $ } from "../utils/shell.ts";
import type { ToolResult } from "./shared.ts";
import { tool } from "./shared.ts";
import { handleToolError, handleToolSuccess, tool, type ToolResult } from "./shared.ts";
export const DebugShellCommand = type({});
@@ -13,33 +12,13 @@ export const DebugShellCommandTool = tool({
execute: async (): Promise<ToolResult> => {
try {
const result = $("git", ["status"]);
return {
content: [
{
type: "text",
text: JSON.stringify(
{
success: true,
command: "git status",
output: result.trim(),
},
null,
2
),
},
],
};
return handleToolSuccess({
success: true,
command: "git status",
output: result.trim(),
});
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
},
],
isError: true,
};
return handleToolError(error);
}
},
});