- JavaScript 83%
- Python 17%
Game Host Kit #
A small, shared way for games published as web tiles and the pages that host them to talk: who's playing, their character, and saving a result to the player's own account, with the player always asked first.
A web tile is sealed: it can't reach the network, can't see who is signed in, and can't write anywhere. That's what makes tiles safe to run from anyone. So a game asks its host, and the host decides. This kit is the set of messages for those questions, carried over the tiles spec's own data channel (tp-data), and two small helpers so neither side has to write the plumbing.
It is a convention for games, built on web tiles; it isn't part of the tiles spec.
- PROTOCOL.md: the messages, version 1.
- CHECKLIST.md: what to check before you call your host or game done.
host/game-host.js: the host's helper.game/game-client.js: the game's helper. Plain JavaScript modules, no packages, no build step. MIT licence.
What version 1 covers #
| The game asks… | The host… | |
|---|---|---|
| Hello | "I'm a game, what can you do?" | says what it offers. A game shows a feature only once it's offered, so on a page that offers nothing the game simply plays. |
| Who's playing | tells the game the player's DID and handle, or that no one is signed in, and again whenever that changes. Players can choose to stay anonymous. | |
| Their character | for the player's rpg.actor character | hands over the sprite sheet and the character's whole entry as rpg.actor publishes it (stats and all). |
| Saving | to save its own record (a score, a run) | asks the player, adds which game and exact version it was, and writes it to the player's account. |
| Opening | to show a record it saved, or a person | decides where to go (a profile page, the player's preferred app) and checks with the player first. |
Version 1 is what Cosmic Junkyard and its hosts already speak, written down, plus a few optional additions. Games and hosts written before the kit keep working with it.
For a host #
Copy host/game-host.js into your site. When you load a game tile into an <iframe>:
import { attachToFrame } from "./game-host.js";
const host = attachToFrame(iframe, {
// The tile you actually loaded: its address and its record's CID (never taken from the game).
tile: () => ({ uri: "at://did:plc:…/ing.dasl.masl/3abc…", cid: "bafyrei…" }),
// Who's signed in, or null.
player: () => (signedIn ? { did: account.did, handle: account.handle } : null),
// The player's character, or null when they have none.
character: async (player) => {
const c = await findCharacter(player.did); // e.g. from rpg.actor's Compendium tile
return c && { image: c.pngBlob, frameWidth: c.frameWidth, frameHeight: c.frameHeight,
sheetWidth: c.sheetWidth, sheetHeight: c.sheetHeight, from: "compendium", entry: c.entry };
},
// Saving: which collections this tile may save into, and how you save.
save: {
collections: (tile) => (tile.uri === MY_GAME ? ["com.example.game.run"] : []),
write: async ({ collection, record, game, status }) => {
// Check the record against the game's lexicon; add $type, createdAt and `game` (the tile you loaded).
status("asking");
if (!(await askThePlayer(record))) return { ok: false, error: "declined" };
status("saving");
const { uri } = await createRecord(collection, { $type: collection, ...record, game, createdAt: new Date().toISOString() });
return { ok: true, uri, handle: account.handle };
},
},
openRecord: (uri) => showRecord(uri),
openProfile: (did) => showPerson(did), // you decide where a person goes
});
// When someone signs in or out: host.playerChanged();
// When you load the frame again: host.reset(); (a new src, a reload: the game starts afresh)
// When the frame goes away: host.detach();
Leave out any function and your host simply doesn't offer that part; games then hide it. examples/host.html is a
complete, made-up host you can read alongside this.
The rules a host keeps are in PROTOCOL.md: you decide; you ask the player before writing anything, outside the tile; you fill in which game and version it was; you answer only what you support; a player can stay anonymous.
For a game #
Put game/game-client.js in your tile next to your index.html:
import { connectToHost } from "./game-client.js";
const host = await connectToHost(); // finds the host, says hello
host.on("offers", () => {
characterButton.hidden = !host.offers("character");
saveButton.hidden = !host.canSave("com.example.game.run");
});
host.on("player", (player) => { /* { did, handle }, or null */ });
host.on("character", (c) => { /* c.image, c.frameWidth, c.frameHeight, c.entry (rpg.actor's own entry) */ });
characterButton.onclick = () => host.requestCharacter();
saveButton.onclick = async () => {
// Only your game's own fields: the host adds which game and version it was.
const r = await host.save({ collection: "com.example.game.run", record: { score } });
if (r.ok) showSaved(r.handle, r.uri); else showNotSaved(r.error); // declined, not-allowed, invalid, failed
};
profileButton.onclick = () => {
if (!host.openProfile(host.player.did)) window.open(`https://bsky.app/profile/${host.player.did}`); // no host: a plain link
};
The game needs its own lexicon and collection for anything it saves, under a domain you control; hosts check records against it. Cosmic Junkyard's README shows one way to do that, with a script to publish the lexicon.
examples/game.html is a tiny game using all of this. examples/tile/ is the same game as a published web tile
(below).
The demo tile #
examples/tile/ is the example game as a web tile, published from this project's account,
colorado.atprotocol.space: index.html, an exact copy of
game/game-client.js beside it (the tests check it stays one), an icon and manifest.json (its name, description and
size). Its address and the files each version was made from are in examples/tile/published.json once it's published.
On a host that saves for other games but not this one, it hides Save and says so.
To publish it, or update it in place after a change (Node 22, no packages; an app password for the project's account):
node scripts/publish-demo.mjs --dry-run
node scripts/publish-demo.mjs
The first run makes a new tile record; later runs keep its address and upload only what changed. It prints a link to
play the demo in Raku. After changing game/game-client.js, copy it into examples/tile/ again.
Try it #
The examples run on any local web server. From this folder, for example:
python -m http.server 8000
then open http://127.0.0.1:8000/examples/host.html. Pick who's signed in, click, save, switch accounts, and watch the
messages on the right. To try another game in the example host: examples/host.html?game=path/to/your/index.html.
Tests #
npm test
Node 22, no packages: the two helpers against each other, and against the messages Cosmic Junkyard and its hosts already
use; the demo tile and its publishing script (test/demo.test.mjs, against a stand-in account server); and stress tests (test/stress.test.mjs): a game that misbehaves (hellos in a loop, floods of saves, malformed, huge
or deeply nested messages), bad timing (switching accounts while a character loads or mid-save, the frame loaded again
mid-save), and two games on one page. test/browser/check_examples.py (Python with Playwright and Chromium) drives the example pages, and Cosmic
Junkyard itself if you give it the game's tile folder.
Who uses it #
- Cosmic Junkyard: the first game (the character and saving runs, since October and November 2026).
- Raku, a browser for web tiles: a host for both, speaking version 1 (who's playing, the whole character, profiles) since November 2026.
About this project #
The Game Host Kit is an independent, non-commercial community project, maintained by its contributors. It's part of the wider ecosystem of developers, communities and users building interoperable apps, games and services across the AT Protocol network, so that what one person makes can work with what others make. It isn't affiliated with or endorsed by Bluesky, the AT Protocol project, or the authors of the web tiles specification.
It's built on AT Protocol (atproto) and on web tiles, and uses those names only to describe what it works with. "AT Protocol", "atproto" and "atprotocol" are trademarks of Bluesky, used here under its trademark policy.
The kit is a convention between games and the pages that host them; it isn't part of the web tiles specification or of AT Protocol itself. Ideas, issues and pull requests are welcome.
Versions and changes #
Version 1 (November 2026). Later versions only add: new messages and new optional fields, never changing what an existing one means. Ideas and changes are welcome as issues and pull requests here.
Licence #
MIT: see LICENSE.