@gguf/claw
Version:
Multi-channel AI gateway with extensible messaging integrations
26 lines (25 loc) • 831 B
TypeScript
import type { Stats } from "node:fs";
import type { FileHandle } from "node:fs/promises";
export type SafeOpenErrorCode = "invalid-path" | "not-found" | "symlink" | "not-file" | "path-mismatch" | "too-large";
export declare class SafeOpenError extends Error {
code: SafeOpenErrorCode;
constructor(code: SafeOpenErrorCode, message: string, options?: ErrorOptions);
}
export type SafeOpenResult = {
handle: FileHandle;
realPath: string;
stat: Stats;
};
export type SafeLocalReadResult = {
buffer: Buffer;
realPath: string;
stat: Stats;
};
export declare function openFileWithinRoot(params: {
rootDir: string;
relativePath: string;
}): Promise<SafeOpenResult>;
export declare function readLocalFileSafely(params: {
filePath: string;
maxBytes?: number;
}): Promise<SafeLocalReadResult>;