/** * The edge of a callable: what happens when a function or node is entered. * * A function's `@capabilities` tag names what it needs from the host. The * generated code carries that list in the wrapper's metadata, and the two * places a callable starts, `AgencyFunction.invoke` and the compiled node * body, both go through `enterCallable` here. Nothing else checks a * capability or writes the capability log. See * docs/dev/language/capabilities.md. */ import { type Capability } from "../host/host.js"; import type { Run } from "./asyncContext.js"; import { type ResultFailure } from "./result.js"; /** * Run `body` if the run's host has every capability in `capabilities`, * else return `refused(run, failure)` without running it. Both are handed * the run, as every body the runtime calls back is * (docs/dev/compiler/codegen-run-parameter.md). The failure is the * host's own refusal, converted the way the generated catch converts one * thrown inside a body, so a refusal at entry and a refusal from inside the * host read the same and log the same, with one sentence added that says * calling again will not help. * * The body never begins, so its `pushHandler` calls never run, and no * handler is skipped by a partial run. This is the argument * `checkFailureArgs` makes for failure propagation, and it holds here for * the same reason: a call that never started cannot raise an effect past an * unregistered handler. * * When the host has an `onCallable` (the test runner's host does, for * `agency test --check-capabilities`), this is also where it hears that a * callable started and ended. The exit is reported in a `finally`, so a body * that throws, fails, or is aborted still leaves the runner's stack; a * missed exit would cover every later host use in the case. */ export declare function enterCallable(run: Run, name: string, capabilities: Capability[], body: (run: Run) => Promise, refused?: (run: Run, failure: ResultFailure) => T): Promise; /** The failure for entering `name` on a host that lacks one of * `capabilities`, or null when the host has them all. */ export declare function refusalAtEntry(run: Run, name: string, capabilities: Capability[]): ResultFailure | null;