@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.
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.
Create a branch or a tag
createRef(slug, name, kind, versionId?, options?) points a named ref at a version. kind is "branch" or "tag".
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
- Gate a pull request for push, dispatch and gate as one call.
- Worlds hub for the same operations in Python.
- The gateway CLI for
gateway bench pushand the version commands.