rojects/source/server/rojos/tools/GetTextContentTool.ts

34 lines
829 B
TypeScript
Raw Normal View History

import { RojoTool, RojoToolContext } from "./RojoTool";
import { readProjectFile } from "../../storage";
2026-07-30 06:44:46 +00:00
export class GetTextContentTool extends RojoTool
{
readonly Definition =
{
type: "function",
function:
{
name: "get_text_content",
description: "Read and return the text content of a file.",
parameters:
{
type: "object",
properties:
{
path: { type: "string", description: "Path relative to the project root." },
},
required: [ "path" ],
},
},
};
async execute( args: Record<string, unknown>, ctx: RojoToolContext ): Promise<unknown>
{
const content = readProjectFile( ctx.projectId, args.path as string );
if ( null === content ) return { error: "File not found or unreadable" };
return content;
}
}