@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
73 lines • 4.06 kB
TypeScript
import { type CompiledProfile, type SessionProfile } from '../../policy/profile.ts';
import type { ProfileScripts } from '../../policy/types.ts';
import type { MountMode } from '../../types.ts';
import { type SessionState } from './session.ts';
/**
* The profile a session is created from. A name is looked up as written; a
* profile object is itself; null picks `profiles.default` when the
* workspace defines one and leaves the session unrestricted otherwise.
* There is no inheritance chain: a profile is the whole document, so
* nothing is assembled from somewhere else before it is read. Throws
* PolicyError on a name the workspace does not define.
*/
export declare function resolveProfile(profiles: Readonly<Record<string, SessionProfile>>, profile: string | SessionProfile | null | undefined): SessionProfile | null;
/**
* A profile with the inline document of one `createSession` added.
*
* The one rule about combining two documents: an inline document may
* add ask and deny rules and hides, never an allow list and never a
* script, and that holds even when there is no profile to add to. Modes
* take the weaker of the two, `cwd` and `env` are the inline document's
* when it states them (they are session presets, not permissions).
* Either side null returns the other unchanged; the profile's policy
* survives the merge, since the inline document can only add rules
* beside it.
*/
export declare function withInline(base: SessionProfile | null, inline: SessionProfile | null): SessionProfile | null;
/**
* The profile's policy programs by method, compiled onto the session.
* `name` is the profile's name, empty for a document passed without one;
* what a program reads as `ctx.profile`.
*
* @throws PolicyError - a program is still a path, which means it
* reached the workspace without passing the config loader that loads one.
*/
export declare function compileScripts(effective: SessionProfile, name: string): ProfileScripts;
/** The session fields a profile compiles to. */
export declare function compileProfile(effective: SessionProfile | null, name?: string): CompiledProfile;
/**
* Stamp a compiled profile's narrowing onto a session: the fields no
* shell line can edit (the per-mount modes, hidden paths, show entries,
* hidden variables, hide reasons, the admission rules, the profile's
* script, the profile's name). Applied at creation and again
* whenever a stored record could carry a stale copy (the default
* session after hydration), so the document, not the store, is what an
* agent runs under.
*/
export declare function narrow(session: SessionState, compiled: CompiledProfile): void;
/**
* The narrowing a session holds, as the compiled profile `narrow` stamps
* back unchanged: how a recorded session's restrictions land on another,
* the inline document and every later profile change kept. Mirrors
* Python `narrowing_of`.
*/
export declare function narrowingOf(session: SessionState): CompiledProfile;
/**
* Two sets of per-mount caps held at once: every prefix either one caps,
* at the weaker mode, so the result is never wider than either. Mirrors
* Python `stricter_modes`.
*/
export declare function stricterModes(a: ReadonlyMap<string, MountMode> | null, b: ReadonlyMap<string, MountMode> | null): ReadonlyMap<string, MountMode> | null;
/**
* Narrow a fresh session and seed its scratch state from the profile.
* A profile's env speaks the workspace `env` block's grammar, so a bare
* string is exported: seeding it plain left `$TOKEN` expanding while
* every command, CLI and guest runtime in the profiled session saw
* nothing, since all three read `envSnapshot` and that is the exported
* set. A managed entry lands as its pointer, fetched when a line names
* it. The cwd is where the session starts; both are the agent's to
* change afterwards, which is why hydration keeps the stored ones and
* re-stamps only `narrow`.
*/
export declare function applyProfile(session: SessionState, compiled: CompiledProfile): void;
//# sourceMappingURL=resolve.d.ts.map