This commit is contained in:
seb
2026-10-10 14:04:58 +02:00
parent 188b8efe09
commit f110173e57
8 changed files with 397 additions and 96 deletions

View File

@@ -2,6 +2,7 @@ import fs from 'fs';
import path from 'path';
import { defineTool, ToolError } from 'libllmorbiter';
import { isSkillPath, parseSkill, SKILL_EXT } from './skill.js';
import { getApiRouteSkill } from './routes-skills.js';
import { prepareVfs } from './vfs.js';
const DEFAULT_LIMIT = 400;
@@ -109,17 +110,18 @@ export function createReadFileTool({ googleAuthId }) {
throw new ToolError(`Access denied: path "${filename}" escapes virtual filesystem boundary.`);
}
if (!fs.existsSync(absPath)) {
const virtualSkill = !fs.existsSync(absPath) && isSkillPath(clean) ? getApiRouteSkill(clean) : null;
if (!virtualSkill && !fs.existsSync(absPath)) {
throw new ToolError(
`File not found in virtual filesystem: "${clean}". ` +
'Call find_files to see what is stored, or find_files({ skills: true }) for SKILL files.'
);
}
if (!fs.statSync(absPath).isFile()) {
if (!virtualSkill && !fs.statSync(absPath).isFile()) {
throw new ToolError(`"${clean}" is not a file. Use find_files to list directories.`);
}
const raw = fs.readFileSync(absPath);
const raw = virtualSkill ? Buffer.from(virtualSkill.content, 'utf8') : fs.readFileSync(absPath);
if (looksBinary(raw)) {
const ext = path.extname(clean).toLowerCase();
throw new ToolError(