Skip to main content
@withgateway/sdk/worlds is how a Node process names a world and runs against it. A world resolves to one pinned version, that version has a task list, and a run of it comes back graded. Every function on this page takes an optional WorldsClientOptions object ({ host, publicKey, secretKey }) as its last argument. Omit it and the three environment variables are used.

Resolve a world to a pinned version

openWorld(slugRef, options?) takes a slug or a slug@ref, where the ref is a branch, tag, semantic version or content hash. It returns a WorldSet without downloading the bundle, because the task list comes from the version’s file manifest.
world.version is a ResolvedWorldVersion: versionId, semanticVersion, contentHash and state. Pin runs to versionId whenever a suite must not split across two versions mid-flight.

Find one scenario

world.tasks holds a WorldTask per scenario, each with a name and a variant parsed from the name. world.task(variant) returns the first task whose variant matches, or whose name contains the string, and throws with the known names when nothing matches.
A WorldSet is identity and data only. To execute anything, either open a live session (world.open, see World sessions) or dispatch a hosted run (world.dispatch, below).

Run configs name what a run executes

A run config is a saved selection: which models to run, how much parallelism, and which scenarios or stored tasks to work through. Continuous integration resolves a config by name and dispatches it by id.
upsertRunConfig(input, options?) creates a config, or updates the one named by input.id.
A config runs either the bundle’s own scenarios or the project’s stored tasks, never both. parseWorldTaskRefs(spec) turns id or id@version items, comma-separated or as an array, into the worldTasks shape. A ref without a version runs the task’s current version at dispatch time.

Dispatch a hosted run

world.dispatch(runConfigId, opts?) starts the run on the platform. The platform executes the world in parallel containers and files one graded run per model.
opts accepts containerId, versionId to pin a version other than the world’s own, and provenance to override what was detected.

Provenance is detected, not configured

Every dispatch carries the branch, commit, repository and actor it came from. detectProvenance() reads the GitHub Actions environment first, then falls back to the local git checkout.
Outside git and outside CI the object comes back empty and the dispatch still goes through.

Read the verdict

getRun(runId, options?) returns a RunReport in one request. waitForRun(runId, opts?) polls until the run is terminal.
waitForRun polls every 20 seconds for up to 45 minutes by default, and throws when the run is still running past the deadline.

The RunReport shape

A score of null means the run was not scored. Treat it as a failure of a score gate rather than as a zero, which is what validateWorld does.

Set a world’s secrets

A world that calls a real service holds its credentials on the platform, never in the bundle. The three helpers are write-only: no endpoint returns a secret’s value.

Call any public endpoint

apiRequest(options, method, path, body?) is the authenticated request the worlds helpers are built on. Use it to call any REST API route directly.
The first argument is the same { host, publicKey, secretKey } object every other function takes. Pass {} to use the environment. Describe a world covers reading what a world holds and finding a redacted row from the plaintext you know.

Where to go next