@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
40 lines • 2.17 kB
TypeScript
import type { Policy } from '../base.ts';
import { SESSION_SCOPED, type SessionScopedMixin } from '../mixin.ts';
import { type Action, type CommandContext, type PolicyMethod, type SessionCommandsQuery, type VfsContext } from '../types.ts';
/**
* The profile's `commands` rules, enforced.
*
* Seeded by the workspace after `MountRootPolicy` (POSIX messages still
* win) and before user policies, so a document rule speaks before a
* coded one when both match. It reads the session's compiled rules
* through the narrow `SessionCommandsQuery` by the session id the entry point
* put in the context, never through ambient state: an explicit fact
* survives the async hop that drops a store. Verdicts render through
* the one outcome table (`renderDeny`), so an agent cannot tell a
* document deny from a coded one.
*
* `preCommand` renders one `decide` call, which is where the law lives:
* the allow list first (a line it does not cover is refused whole,
* though its head was visible), then the winning rule, refused whole or
* per operand by whether it names paths, or taken to the approval ledger
* when it asks. `preVfs` reads the rules that are pure paths, deny and ask
* alike (`opRuling`), so FUSE, programmatic ops and the warm cache cannot
* bypass a path the profile protects. A path rule that asks is a question only where no
* line is running (a file tool, the host's facade), which the entry point puts
* to the approval ledger keyed by rule and path; inside a line it
* refuses, since the line was admitted without it.
*/
export declare class PermissionsPolicy implements Policy, SessionScopedMixin {
readonly [SESSION_SCOPED]: true;
private readonly sessions;
constructor(sessions: SessionCommandsQuery);
preCommand(ctx: CommandContext): Action | null;
preVfs(ctx: VfsContext): Action | null;
/**
* Whether this session's rules speak at `method`: always at command
* admission, and at the dispatcher only through a pure path rule, the one kind
* an op can meet (`opRuling`).
*/
wantsFor(method: PolicyMethod, sessionId: string): Promise<boolean>;
}
//# sourceMappingURL=permissions.d.ts.map