@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
53 lines • 2.6 kB
TypeScript
import { LanguageRuntime } from '../language.ts';
import type { Argv0Rules } from '../source.ts';
import type { RunResult, Language } from '../types.ts';
import type { RuntimeOptions } from '../config.ts';
/** CPython's own four answers, pinned on 3.12.13/3.13.7. */
export declare const CPYTHON_ARGV0: Argv0Rules;
/**
* The program that `-m mod` runs, on any engine that is real CPython.
*
* runpy does the work: run_module finds the module, runs it under
* __main__, and alter_sys rewrites sys.argv[0] to the module's own
* file, which is what CPython puts there. Engines that are not CPython
* declare runsModules false and never see this.
*
* The existence probe is not redundant with run_module: CPython answers
* a missing module with one line and exit 1, while bare run_module
* raises, which would reach the user as a runpy traceback. Probing
* first also keeps an ImportError raised INSIDE the module distinct
* from the module itself being absent, which a try around run_module
* could not tell apart.
*
* @param name the module to run.
* @param label the command name used in the not-found message.
*/
export declare function moduleSource(name: string, label: string): string;
/**
* The python tier: every runtime that interprets Python source.
*
* Groups the engines behind the python3/python commands (pyodide,
* monty here; wasi, local in Python and @struktoai/mirage-node), so
* `language` and the default captures are declared once and
* python-tier behavior has one home. A new Python engine subclasses
* this, not LanguageRuntime.
*/
export declare abstract class PythonRuntime<E = unknown> extends LanguageRuntime<E> {
readonly language: Language;
/** The tier's head words: the class-default captures of every python engine. */
static readonly commands: readonly string[];
readonly argv0Rules: Argv0Rules;
/**
* Whether `python3 -m mod` can run at all. True for every engine that
* is real CPython, since runpy does the work; false for an engine
* implementing a subset of the language with no import system to find
* a module with. A capability of the tier, declared here rather than
* probed, so a refusal can name the runtime.
*/
readonly runsModules: boolean;
protected readonly versionSuffix: string;
moduleCode(name: string, label: string): string | null;
version(env: Record<string, string>, signal?: AbortSignal, timeoutSeconds?: number): Promise<RunResult>;
constructor(options?: RuntimeOptions<object>, configKeys?: readonly string[]);
}
//# sourceMappingURL=base.d.ts.map