@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
35 lines • 1.27 kB
TypeScript
import type { Files } from '../files.ts';
import { type ReadFileMime } from './read_file/constants.ts';
interface WorkspaceFileBase {
path: string;
mimeType: ReadFileMime;
bytes: number;
}
export type WorkspaceFileReadResult = (WorkspaceFileBase & {
kind: 'text';
content: string;
}) | (WorkspaceFileBase & {
kind: 'image';
data: Uint8Array;
}) | (WorkspaceFileBase & {
kind: 'file';
data: Uint8Array;
filename: string;
}) | (WorkspaceFileBase & {
kind: 'binary';
note: string;
});
export type WorkspaceMediaRead = Extract<WorkspaceFileReadResult, {
kind: 'image' | 'file';
}>;
export type WorkspaceFileReader = (path: string) => Promise<Uint8Array>;
/**
* A file a model takes as media, from the bytes already read: an image
* the models read, or a PDF. Its extension decides; a name with none is
* sniffed from its bytes alone, so no stat is needed beyond the read.
* Undefined for anything else, which the text read answers.
*/
export declare function mediaOf(path: string, data: Uint8Array): WorkspaceMediaRead | undefined;
export declare function readWorkspaceFile(vfs: Files, path: string, reader?: WorkspaceFileReader): Promise<WorkspaceFileReadResult>;
export {};
//# sourceMappingURL=read_file.d.ts.map