@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
38 lines • 1.85 kB
TypeScript
import type { PathSpec } from '../../types.ts';
import type { Program } from '../types.ts';
export declare const PAYLOAD_ARGV0 = "-c";
export declare const STDIN_ARGV0 = "-";
/**
* The file CPython runs a program from, named the way it names it.
*
* A script and a program piped to stdin both come through CPython's file
* entry point, which binds `__file__` to the file's name and compiles every frame
* under it: the script operand made absolute against the working
* directory as typed, never normalized (`./s.py` under /w is `/w/./s.py`),
* or `<stdin>` for either stdin spelling. A payload, a module and a script
* CLI come through no file. Pinned on CPython 3.13.5; mirrors Python's
* main_filename.
*
* @param program the run, whose `scriptPath` and `prog` say which entry
* point the source came through.
* @param cwd the working directory a relative script is made absolute
* against.
*/
export declare function mainFilename(program: Program, cwd: PathSpec | null): string | null;
/**
* Wrap a program so a `-c` subprocess runs it the way CPython would.
*
* CPython hardcodes argv[0] to "-c" for a `-c` program, names every frame
* "<string>" and binds no `__file__`, which is right for a payload and
* wrong for the other entry points, so the program is re-compiled under its own
* name with what CPython's file adapter binds. It also binds the script-CLI
* contract before compiling the unmodified program. Mirrors Python's
* prepare_source.
*
* @param program the run. A `prog` of none or "-c" with no script file
* means a payload, which CPython already reports correctly and which
* passes through untouched.
* @param cwd the working directory the script is named against.
*/
export declare function prepareSource(program: Program, cwd: PathSpec | null): string;
//# sourceMappingURL=execution.d.ts.map