@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
75 lines • 4.43 kB
TypeScript
import { Limit, type Producer } from '../../types.ts';
export declare const DEFAULT_COMMAND_LIMITS: Record<string, Limit>;
/** The line's time limit when no `@line` entry names one. Mirrors Python's LINE_TIMEOUT_SECONDS. */
export declare const LINE_TIMEOUT_SECONDS = 600;
/**
* The entry naming every command in a limit table, a group spelled with the
* `@` a runtime's captures use for theirs, so no command name can clash.
* Mirrors Python's ALL_COMMANDS.
*/
export declare const ALL_COMMANDS = "@all";
/** The entry naming the whole line, whose `timeoutSeconds` is its one time limit. Mirrors Python's LINE. */
export declare const LINE = "@line";
/** What a line past its time limit is called: `line: timed out after Ns`. Mirrors Python's LINE_NAME. */
export declare const LINE_NAME = "line";
interface LimitMount {
commandLimits: Map<string, Limit>;
defaultLimit: Limit;
}
/**
* A command's own entry in a limit table, or null. Command names are
* script-controlled, so `toString` must not resolve an `Object.prototype`
* member of a table built with `{...}`.
*/
export declare function ownLimit(table: Readonly<Record<string, Limit>>, name: string): Limit | null;
/**
* Resolve one command's limit, the one precedence engine.
*
* Field by field, from the most specific layer that sets it: the profile's
* entry for the command, then its `@all` entry for every command, then the
* mount's two, the workspace's two, the command's own default and the
* built-in table; on a mount, its backend's default (`walkLimit`) last. A layer that names one bound inherits the rest. A command across
* several mounts resolves on each and keeps the tightest bound. Mirrors
* Python's resolve_limit.
*/
export declare function resolveLimit(name: string, mounts?: readonly LimitMount[], commandDefault?: Limit | null, mountOverride?: Limit | null, workspaceLimits?: Readonly<Record<string, Limit>>, profileLimits?: Readonly<Record<string, Limit>>): Limit | null;
/**
* How many files one walk lists on `mount`, -1 for no cap: the `walkLimit`
* of `command`, resolved as resolveLimit resolves every bound; without a
* command, the one every command shares (the `*` entries), which a glob
* counts against. A layer naming the bound as null lifts it. Mirrors
* Python's walk_bound.
*/
export declare function walkBound(mount: LimitMount, command?: string | null, commandDefault?: Limit | null, workspaceLimits?: Readonly<Record<string, Limit>>, profileLimits?: Readonly<Record<string, Limit>>): number;
export type MountLookup = (prefix: string) => LimitMount | null;
/**
* Resolve producer facts for command output guards and dispatch timeouts,
* through the same layers as resolveLimit on the mounts its prefixes name.
* Mirrors Python's resolve_producer.
*/
export declare function resolveProducer(producer: Producer, mountAt: MountLookup, workspaceLimits?: Readonly<Record<string, Limit>>, profileLimits?: Readonly<Record<string, Limit>>): Limit | null;
/** The canonical snake_case command-limit mapping used by config and stored sessions. */
export declare function parseCommandLimits(raw: unknown): Record<string, Limit>;
/**
* A limit table as config spells it, each entry with only the fields it names
* (a null among them), so a stored entry still inherits the rest. Mirrors
* Python's command_limits_to_json.
*/
export declare function commandLimitsToJSON(limits: Readonly<Record<string, Limit>>): Record<string, unknown>;
/**
* The whole line's deadline, the one time limit a line runs under: the
* `@line` entry's `timeoutSeconds`, the profile's over the workspace's, else
* `LINE_TIMEOUT_SECONDS`. An entry naming it as null or 0 lifts it. Mirrors
* Python's line_timeout.
*/
export declare function lineTimeout(workspaceLimits?: Readonly<Record<string, Limit>>, profileLimits?: Readonly<Record<string, Limit>>): number | null;
/**
* Refuse a table that names time where no time limit applies. A line runs
* under one time limit, the `@line` entry's `timeoutSeconds`; no command or
* op entry takes one, and the `@line` entry takes nothing else. A mount
* names no line, since a line spans mounts. A key is a command or one of the
* two groups, `@all` and `@line`. Mirrors Python's check_command_limits.
*/
export declare function checkCommandLimits(limits: Readonly<Record<string, Limit>>, where: string, takesLine: boolean): void;
export {};
//# sourceMappingURL=output_cap.d.ts.map