UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

61 lines • 3.03 kB
import { type FileStat, PathSpec } from '../../../../types.ts'; import { type WalkCall } from '../../utils/tree.ts'; import { type DuEntries } from '../../generic/du.ts'; import type { LinkView, MountView } from '../../../../view/types.ts'; import type { GenericCommand } from '../adapter.ts'; /** * What the walks of one `du` invocation met. * * Each operand's walk lists at most `walkLimit` entries of each mount it * crosses (`WalkBudget`): a walk the mount's `readTree` does not answer takes * one `readdir` per directory, which on an API-backed tree is one request per * directory. Slack, for instance, exposes a directory per channel per day, so * an unbounded walk of a real workspace is tens of thousands of requests. * Where a walk ran out is kept, so the answer says it is partial. */ export declare class DuTally { readonly mounts: MountView | null; readonly stopped: string[]; readonly unreadable: string[]; readonly directories: string[]; readonly inaccessible: [string, string | null][]; constructor(mounts?: MountView | null); } interface Walk { readdir: WalkCall<string[]>; stat: WalkCall<FileStat>; } /** * What `du -L` follows links by, for one invocation. * * GNU counts each file once, under the first name its walks meet, across * every operand of the line (coreutils 9.7): what one operand reaches is not * counted again under another, and an operand already counted prints * nothing. A link leading back into its operand's own tree waits for * the walk to end, and counts only if the walk never reached the file under * the file's own name: mirage's sorted walk prefers that name (where GNU's * readdir order may reach the link first), and a directory the walk may not * list leaves the link the one name that reaches the file, which GNU then * counts it under. Under `-x` a link that leads onto another mount is left out * whole, as GNU leaves out what stat(2) places on another device. */ declare class Dereference { readonly links: LinkView; readonly mounts: MountView | null; readonly counted: Set<string>; readonly tree: string; readonly home: string | null; readonly waiting: [PathSpec, string][]; constructor(links: LinkView, mounts: MountView | null, counted?: Set<string>, tree?: string, home?: string | null, waiting?: [PathSpec, string][]); /** This invocation's state, walking one operand. */ operand(path: PathSpec): Dereference; /** The same walk, settling a link into its tree under the link's name. */ under(link: PathSpec): Dereference; /** Whether an earlier operand's walk already counted this one. */ repeated(path: PathSpec): boolean; } export declare function walkSize(walk: Walk, tally: DuTally, follow: Dereference | null, path: PathSpec): Promise<number>; export declare function walkEntries(walk: Walk, tally: DuTally, follow: Dereference | null, path: PathSpec): Promise<DuEntries>; export declare const BUILDER: GenericCommand; export {}; //# sourceMappingURL=du.d.ts.map