UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

49 lines • 2.91 kB
import type { SessionView } from '../../view/types.ts'; import type { ArithWrite } from '../../shell/types.ts'; import type { SessionState } from './session.ts'; import { RandomReader } from './state.ts'; /** * Whether a `name` / `name[sub]` reference names a set value. * * What `test -v` asks. A bare name over an array checks element 0 (the * literal key `"0"` for an associative one), which is GNU's rule; * `name[@]` and `name[*]` ask whether any element is set. An * associative subscript is the key verbatim; an indexed one evaluates * as arithmetic, and its assignments land through `view` * (`[[ -v a[x=2] ]]` leaves x at 2, as bash does); null lands them * ungated, outside a workspace. */ export declare function elementIsSet(session: SessionState, ref: string, view?: SessionView | null): Promise<boolean>; /** * Assign one element (or a bare name resolved as element 0). * * The element mechanics are computed on a copy and the landing write * goes through the session view as the whole variable the write produces, so a * refused write leaves nothing half-applied and a `preSession` rule * sees `m[k]=v` as a write to `m`. The subscript arrives already * expanded: an associative name takes it as the key verbatim, an * indexed one evaluates it as arithmetic. A null subscript is a bare * target, which bash resolves as element 0 of an array and a plain * scalar otherwise. Answers `"ok"`, `"denied"`, `"readonly"`, or * `"subscript"`; a preSession refusal from the session view propagates so the * rule's own message reaches the caller. */ export declare function assignElement(session: SessionState, view: SessionView | null, name: string, subscript: string | null, value: string, append?: boolean): Promise<'ok' | 'denied' | 'readonly' | 'subscript'>; /** * Land an arithmetic command's assignments in the order the expression made * them, each through the session view: a hidden name throws PolicyDenied and the * ones after it never land, as a readonly name stopped the evaluation itself * (`let 'X=5, R=3'` leaves X at 5). The draws made after a seed that landed * settle either way. Mirrors Python's land_arith. */ export declare function landArith(session: SessionState, view: SessionView | null, writes: readonly ArithWrite[], reader: RandomReader): Promise<void>; /** * Evaluate `text` as an arithmetic command or expansion does and land what * it assigned through `land`, which settles its `RANDOM` draws. Reads * resolve against the visible env, so a hidden name counts as unset, and * bash bound the assignments made before an error, which land before the * error is thrown; a PolicyDenied from `land` wins over it. Mirrors * Python's landed_arith. */ export declare function landedArith(session: SessionState, view: SessionView | null, text: string, land?: typeof landArith, nounset?: boolean): Promise<bigint>; //# sourceMappingURL=elements.d.ts.map