import { TypeCheckReport } from "../compiler/compile.js"; import type { AgencyProgram, AgencyNode } from "../types.js"; import { AgencyFunction } from "../runtime/agencyFunction.js"; /** * Register a scoped callback for the dynamic extent of the caller's function * or node. Implementation backing for `callback(name, fn)` in std::agency. * * Frame targeting: * - At top level (inside `__initializeGlobals`, before any node frame is * pushed) — route to `ctx.topLevelCallbacks`, which lives on the * execution context for the whole run. * - Otherwise — push onto the caller's stack frame, which auto-cleans up * when the caller's frame pops. * * NOTE on the AgencyFunction wrapping: this function needs access to the * runtime state (to walk the stateStack and find the caller's frame), and * the only way a TS-implemented stdlib export receives that state is by * being wrapped as an AgencyFunction. `__call`'s plain-function branch * silently drops the state argument; the AgencyFunction branch routes * through `invoke()`, which passes state as the last positional arg to the * underlying TS function. See `_run` in `lib/runtime/ipc.ts` for the * established pattern. */ export declare function _callbackImpl(name: string, fn: unknown): void; export declare const _callback: AgencyFunction; export declare function _compile(source: string): { moduleId: string; code: string; }; export declare function resolveInSandbox(dir: string, filename: string, opts?: { mustExist?: boolean; }): string; export declare function _compileFile(dir: string, filename: string): { moduleId: string; code: string; }; /** The current process's subprocess nesting depth (0 = root). Backs the * `depth` field in std::run gate interrupt data — `run()` reports the * PROSPECTIVE child depth as `_subprocessDepth() + 1` so handlers can * reject by depth. Also readable from TS via `agency.ctx().subprocessDepth`. */ export declare function _subprocessDepth(): number; export declare function _typecheck(source: string): TypeCheckReport; export declare function _getEffects(source: string): Record; export type ExportKind = "def" | "node" | "type" | "const" | "reexport"; export type ExportInfo = { name: string; kind: ExportKind; signature: string; docstring: string | null; effects: string[]; destructive: boolean; idempotent: boolean; /** The module path this export was re-exported from, else null. */ reexportedFrom: string | null; }; export type ModuleInfo = { description: string | null; exports: ExportInfo[]; }; /** One ExportInfo per EXPORTED top-level def, node, type alias, const, * and re-exported name, in source order. Effects come from the same * transitive analysis as _getEffects, sentinel included. Re-exports * from std:: modules resolve by describing the source module; other * re-exports (relative paths cannot resolve from a bare source string) * come back as thin "reexport" entries whose effects carry the * "unknown" sentinel — never a silent omission. */ export declare function _describe(source: string): ModuleInfo; export declare function _typecheckFile(dir: string, filename: string): TypeCheckReport; export declare function _parseAST(source: string): AgencyProgram; export declare function _writeAST(ast: AgencyProgram, dir: string, filename: string, overwrite: boolean): Promise; export declare function _format(source: string): string; export declare function _formatFile(dir: string, filename: string): boolean; export type WalkASTVisit = { node: AgencyNode; ancestors: AgencyNode[]; }; export declare function _walkAST(ast: AgencyProgram): { clone: AgencyProgram; visits: WalkASTVisit[]; }; export declare function _getNodesOfType(source: string, types: string[]): AgencyNode[]; export declare function _filterImports(source: string, allowedPackages: string[], excludedPackages: string[], allowKinds: string[], excludeKinds: string[]): { source: string; filtered: boolean; };