Skip to main content
The hub half of @withgateway/sdk/worlds publishes and retrieves world source. A world version is content-addressed, so pushing an unchanged tree files nothing new and every run can name exactly what it ran. The gateway CLI runs on the same code.

Push a checkout as a version

push(dir, opts?) hashes the directory, uploads the bundle, and files a version on a branch.
The return value is { containerId, slug, versionId, contentHash, branch, state, alreadyUploaded }. alreadyUploaded is true when the content hash already existed, so re-pushing an unchanged tree is free.
A continuous integration checkout carries no local metadata, so a re-run would conflict with the version its own previous run created. Resolve the branch tip first and pass it as baseVersionId. validateWorld already does exactly that.

Pull a world down

pull(slugRef, target?, options?) resolves a slug or slug@ref, downloads the bundle, verifies its checksum, and extracts it.
Without a target, the directory is the slug, with a numeric suffix added when that name is taken. The ref defaults to latest. pull writes local metadata under .gateway/ recording the slug, branch, version and a hash of every file. The metadata is what lets propose know which files you changed.
Pulling is for authoring a world. To run against one, resolve it with openWorld instead; running needs no bundle on disk.

Propose a change to a world you do not own

propose(dir, { title, reason, targetBranch?, options? }) sends the edits in a pulled directory as a proposal for the world’s owner to review.
The directory must have been pulled, so there is a base to compare against, and it must actually differ from that base. Both cases throw with a message saying which one happened.

Create a branch or a tag

createRef(slug, name, kind, versionId?, options?) points a named ref at a version. kind is "branch" or "tag".
Without a versionId the ref points at the world’s current head.

Inspect a tree before pushing it

Four helpers expose the content-hash rules.
collectArchiveRelPaths returns the sorted list of files that go into the hash. Dot-files, __pycache__ and the excluded root directories are left out, which is why a stray build directory does not change a version.

Where to go next