UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

54 lines • 2.91 kB
import type { Policies } from '../policy/policies.ts'; import type { NetworkContext } from '../policy/types.ts'; import { type NetworkRule } from './network.ts'; /** * What judges the connections a line or a file op opens: the workspace's * `network` (null for no limit) and its policies, whose preNetwork and * postNetwork each connection answers to. `hooked` settles whether one of * them listens for the session's connections, so each goes through the * gateway, and `listening` holds the answer once it has: the binding starts * the line or the op at once, as a browser's storage must keep its frames in * step, and a connection opened first waits for it. `session` is the * session it runs for (null when unknown), and `op` whether a file op, not a * line, bound it. Mirrors Python's `Egress`. */ export declare class Egress { readonly rule: NetworkRule | null; readonly policies: Policies | null; readonly session: string | null; readonly op: boolean; listening: boolean | null; readonly hooked: Promise<boolean>; constructor(rule: NetworkRule | null, policies: Policies | null, hooked: Promise<boolean>, session?: string | null, op?: boolean); } /** * `fn` run as a line or a file op of a workspace: every connection it opens * clears `rule`, and passes the gateway when a policy listens for the * session's connections; for `session`, null when unknown, and `op` when * a file op, not a line, binds it. Mirrors * Python's `run_with_egress`. */ export declare function runWithEgress<T>(rule: NetworkRule | null, policies: Policies | null, fn: () => Promise<T>, session?: string | null, op?: boolean): Promise<T>; /** * `it` pulled and closed under the egress bound where it was made: a mount's * stream opens each later connection, whoever pulls it and however late, * under the workspace's rule and policies, as `withCaller` keeps its caller. * Its close reaches the stream even before a first pull. Handed back as it * is where neither limits anything. `owner` names the egress outright where * a browser's storage, which answers its newest frame, could hand another * workspace's. Mirrors Python's `with_egress`. */ export declare function withEgress(it: AsyncIterable<Uint8Array>, owner?: Egress | null): AsyncIterable<Uint8Array>; /** * The egress of every call live in this context: on an isolating runtime the * bound one alone, in a browser every concurrently bound one, since it cannot * tell whose call is opening the connection. Mirrors Python's `live_egress`. */ export declare function liveEgress(): readonly Egress[]; /** * The context a connection to `address` on `port`, opened for `host`, * reports: the command, the mount and the session of the call opening it. * Mirrors Python's `_opened`. */ export declare function opened(host: string, address: string, port: number): NetworkContext; //# sourceMappingURL=gateway.d.ts.map