full initial implementation

This commit is contained in:
Shivering Ocelot committed 2026-09-03 23:43:33 -05:00
1 parent 65fc75e509
commit d9d9b7f463
15 files changed
+799 -4

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import fs from 'node:fs';
import path from 'node:path';
export const spec = {
name: 'read_file',
description: 'Read the text content of a file in the space.',
parameters: {
type: 'object',
properties: {
path: { type: 'string', description: 'File path relative to the space directory.' },
},
required: ['path'],
},
};
function resolveIn(base, relPath) {
const resolved = path.resolve(base, relPath);
if (resolved !== base && !resolved.startsWith(base + path.sep)) {
throw new Error('Path escapes the space directory');
}
return resolved;
}
export default async function (args, ctx) {
return { content: fs.readFileSync(resolveIn(ctx.dir, args.path), 'utf8') };
}