app-anything GitHub

Write a runtime provider

Runtime providers make a manifest's runtime requirement concrete: how the backend is launched on the host, and what travels inside the package. The working examples are the three builtin providers in src/app_anything/runtimes/ — python.py (read the whole flow), node.py (lock-driven install), binary.py (prebuilt artifacts) — with their contract tests in tests/contract/test_builtins.py.

1. Register like everything else

@runtime("deno")
class DenoRuntime:
    def accepts(self, requirement: RuntimeRequirement) -> bool:
        return requirement.name == "deno"

The string is the requirement name a manifest may declare; accepts decides whether a runtime: "deno>=2" backend is yours.

2. Launch on the host

def host_launch(self, project: Project, backend: Backend) -> LaunchSpec:
    return LaunchSpec(("deno", "run", "--allow-net", *backend.entry.argv[1:]), cwd=project.root)

LaunchSpec is pure data: argv plus a working directory. The host — dev, the dynamic checks, the probe — builds the environment (chosen PORT, APP_TOKEN, APP_DATA_DIR) and supervises the process; you never manage ports or lifecycles yourself.

3. Collect for the package

collect(...) copies what the package must carry for your runtime to work on another machine — interpreter-independent sources and the lock file in the default source form; per-triple binaries for prebuilt. Return a CollectedBackend; the packer records it in aapkg.json.

4. Contract-check the result

Subclass RuntimeProviderContract from app_anything.sdk.testing and let pytest run it (see tests/contract/test_builtins.py): the suite checks acceptance, the launch spec shape and collection against a real project fixture, so a provider cannot silently diverge from what hosts assume.

Rendered from docs/how-to/write-a-runtime-provider.md on main.