Skip to Content
Docs

Get the Runtime Adapters

Pull the runtime adapter images and copy each language's library out for your editor, tests, and coding agent.

The runtime adapters are not published to npm, crates.io, a Go proxy, or PyPI. Each adapter is a base image on the platform's image host. The Rust, Go, and Python images also contain their language's library. You get both by pulling the image with your Contextual CLI login. You do not need access to the platform source repository.

Before You Start

You need Docker and the Contextual CLI with a signed-in configuration. Follow step 1 of Deploy Your First Worker if you have not set them up.

Configure Docker to use your CLI login for the image hosts:

Terminal
ctxl workers configure-docker --pretty

The Adapter Images

Language Image Library in the Image
TypeScript or JavaScript (Node 24) images.contextual.io/worker/base/worker-adapter-node:0.10.0 None in 0.10.0. The adapter supplies the handler's context at run time. See the TypeScript tab below.
Rust (1.88 or later) images.contextual.io/worker/base/worker-adapter-rust:0.7.0 /opt/contextual/worker-adapter-rust/contextual-worker, the contextual-worker crate
Go (1.26 or later) images.contextual.io/worker/base/worker-adapter-go:0.4.0 /opt/contextual/worker-adapter-go, the contextual.io/worker module
Python (3.14) images.contextual.io/worker/base/worker-adapter-python:0.4.0 /opt/contextual/worker-adapter-python/contextual_worker, the contextual_worker package

Check that you can pull your language's image:

Terminal
docker pull --platform linux/amd64 images.contextual.io/worker/base/worker-adapter-node:0.10.0

If Docker reports unauthorized or denied, see Troubleshooting.

How the Adapter Gets into Your Image

You never install an adapter from a package registry, and you never write the Dockerfile for the image that runs. The adapter image does three jobs:

  • Library. In Rust, Go, and Python, it contains the library your code imports. Copy it into your project for your editor, tests, and coding agent. Its types and doc comments are the most exact API reference for that version.
  • Build input. In Rust and Go, your Dockerfile.build copies the library from the adapter image again and compiles your binary against it.
  • Base image. Its package command writes the Docker build directory for your app image, FROM the same adapter image. The CLI builds and pushes that image when you create or update the Worker.

The whole path, for every language:

  1. Pull and copy. Configure Docker as above, pull your language's adapter image, and copy the library into your project. See Copy the Library into Your Project.
  2. Write the handler against the copied library: a path dependency in Rust, a replace directive in Go, PYTHONPATH in Python. See Write the Handler and Manifest.
  3. Build. Rust and Go compile a linux/amd64 binary with a Dockerfile.build that starts FROM the adapter image. TypeScript bundles the module into one file. Python has nothing to compile. See Build.
  4. Package. Run the adapter image's package command. It checks worker.json, hashes the release, and writes .worker-image, whose Dockerfile is FROM the adapter image. See Package the Release.
  5. Deploy. ctxl workers create --managed <template>:<version> --build .worker-image builds the app image, pushes it to your organization's image host, and deploys it. See Create the Worker.

Use one adapter version for all of it: the library you copy, the Dockerfile.build stage, and the package command. Your local copy and the build stage are two copies of the same library, so a version mismatch builds against one API and runs on another. Deploy it on the template version released with that adapter. See Release Versions.

When you upgrade, change the version in all three places, delete the old copy, and copy the library again. Copying into an existing directory can nest the new copy inside the old one, and it keeps the old files.

Copy the Library into Your Project

Run these commands from your project directory. They copy the library into .contextual/ or the path shown, replacing an earlier copy. Add the copied directory to .gitignore. Each command runs cp inside the image as your own user, so the copied files belong to you.

The 0.10.0 TypeScript image contains no library to copy. Its runner loads your bundled module and supplies the handler's context at run time, so your code imports nothing from the adapter. Install only the build tools:

Terminal
npm install --save-dev esbuild typescript @types/node

Your module default-exports the Worker: an object with apiVersion: "1", name, version, parseConfig, and run, and optionally start and stop. Another handler is a named export function. Until an adapter release publishes the context's types, describe them yourself. Save this as src/worker-types.ts and extend it with the methods you use, from Platform Capabilities:

TypeScript
// The parts of the managed Worker context this app uses. Adapter 0.10.0 publishes no types.
export type Fields = Record<string, unknown>
export type Logger = Record<"debug" | "info" | "warn" | "error", (message: string, fields?: Fields) => Promise<void>>
export type Invocation = { id: string, payload: unknown, trigger: { type: "topic" | "http" | "cron", [field: string]: unknown } }
export type Context<Config> = {
  config: Config
  logger: Logger
  signal: AbortSignal
  invocationId: string
  correlationId: string
  // The capability namespaces (records, attachments, ai, and the rest), typed loosely.
  [namespace: string]: any
}

/** A failed capability call: an Error named PlatformError, with the fields on the Platform Capabilities page. */
export type PlatformFailure = Error & { code: string, reason?: string, retryable: boolean, effectMayHaveOccurred: boolean, responseStatus?: number }
export const isPlatformError = (error: unknown): error is PlatformFailure => error instanceof Error && error.name === "PlatformError"

Bundle your Worker into one CommonJS file with esbuild or another bundler. See Build Your First Managed Worker.

For Rust and Go, your build also copies the library from the adapter image, in a Dockerfile.build stage. The local copy is for your editor and tests. See Build Your First Managed Worker.

Give the Library to a Coding Agent

A coding agent writes better Worker code when it reads the library source than when it guesses from memory. After you copy the library, point the agent at it:

Language What to Point the Agent At
TypeScript src/worker-types.ts and Platform Capabilities. The 0.10.0 image has no library source, so the capabilities page is the API reference.
Rust contextual-worker/src/lib.rs, capabilities.rs, helpers.rs, context.rs, and examples/
Go contextual-worker/README.md, capabilities.go, helpers.go, context.go, and examples/
Python .contextual/README.md, contextual_worker/capabilities.py, helpers.py, context.py, and examples/

See Build with a Coding Agent for a complete brief.