@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
65 lines • 3.08 kB
TypeScript
import { RAMAccessor } from '../../accessor/ram.ts';
import type { ByteSource } from '../../io/types.ts';
import { BaseVFS } from '../base.ts';
import { type StorageUsage } from '../capacity.ts';
import { RAMStore, type RAMAttrs } from './store.ts';
import type { CapacityResult, PathSpec, FileStat, SetAttrFields } from '../../types.ts';
import type { Handed } from '../types.ts';
export interface RAMVFSOptions {
/** The most bytes the store may hold: a size like `100MB` or a count of
* bytes; left out or null, no limit. Every mount of the store shares it. */
capacity?: number | string | null;
}
export interface RAMVFSState {
type: string;
config?: {
capacity?: number;
};
files?: Record<string, Uint8Array>;
dirs?: string[];
modified?: Record<string, string>;
attrs?: Record<string, RAMAttrs>;
}
export declare class RAMVFS extends BaseVFS {
readonly name: "ram";
readonly cachesReads: boolean;
readonly sizesAlwaysKnown: boolean;
readonly indexTtl: number;
readonly usage: StorageUsage | null;
readonly store: RAMStore;
readonly accessor: RAMAccessor;
readonly readsRanges: boolean;
readonly local: boolean;
walkLimit: number;
/** @throws VFSConfigError when `capacity` is not a size. */
constructor(options?: RAMVFSOptions);
/**
* The bytes the store's files hold, which count against the `max_memory`
* of each workspace the store is mounted in; 0 for a table that keeps none,
* as `/dev`'s devices and pipes. Mirrors Python's `held`.
*/
get held(): number;
readTree(path: PathSpec): Promise<Map<string, FileStat> | null>;
readdir(path: PathSpec): Promise<FileStat[]>;
read(path: PathSpec, _handed?: Handed, offset?: number, size?: number | null, signal?: AbortSignal): Promise<ByteSource> | AsyncIterable<Uint8Array>;
stat(path: PathSpec): Promise<FileStat>;
exists(path: PathSpec): Promise<boolean>;
write(path: PathSpec, data: ByteSource, signal?: AbortSignal, _handed?: Handed, atomic?: boolean): Promise<void>;
append(path: PathSpec, data: ByteSource, _handed?: Handed, signal?: AbortSignal): Promise<void>;
pwrite(path: PathSpec, data: Uint8Array, offset: number, _handed?: Handed, signal?: AbortSignal): Promise<void>;
create(path: PathSpec): Promise<void>;
mkdir(path: PathSpec, parents?: boolean): Promise<void>;
unlink(path: PathSpec): Promise<void>;
rmdir(path: PathSpec): Promise<void>;
rmR(path: PathSpec): Promise<void>;
rename(src: PathSpec, dst: PathSpec): Promise<void>;
copy(src: PathSpec, dst: PathSpec, signal?: AbortSignal): Promise<void>;
truncate(path: PathSpec, length: number, noCreate?: boolean): Promise<void>;
setattr(path: PathSpec, fields: SetAttrFields): Promise<Record<string, number | string>>;
getState(): RAMVFSState;
loadState(state: RAMVFSState): void;
/** df's QUOTA row for a capped store; the base UNKNOWN otherwise. Mirrors
* Python's. */
capacity(): Promise<CapacityResult>;
}
//# sourceMappingURL=ram.d.ts.map