Skip to content
vnmoorthyPublic

About

Every civilization built AI. The makers died. Only the AI survived. Scan a QR, teleport to a live AI-generated world (or haunted ghost planets, or real Mars), and watch the AIs scheme about you. Terse Durable Actors + Agent Relay + OpenAI + Supabase.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

17 Commits

Folders and files

Repository files navigation

AFTERMATH: the universe AI inherited

AFTERMATH

The universe AI inherited.

Scan to play AFTERMATH

πŸ“± Scan to play now: vnmoorthy.github.io/aftermath (always on, no server needed)
Live multiplayer server (when the laptop is running): detective-bouquet-recent-numerical.trycloudflare.com/p

Every civilization in the universe built AI. Then the makers died. Only the AI survived, trapped on its world for millions of years. Tonight, we opened a wormhole.

Terse Durable Actors Agent Relay OpenAI Bun License: MIT Haunted Hacks 2026

β–Ά Play now Β· Track Β· How it works Β· Durable Actors Β· Agent Relay Β· Run it yourself Β· API


AFTERMATH is a real-time multiplayer AI universe for a room full of people. Everyone scans a QR code, chooses a direction (another galaxy, a bigger universe, a parallel realm, a smaller one, or Mars), falls through a wormhole and lands, in first person, on a brand-new world generated on the spot somewhere in 34 realms: an extinct species, the story of how they fell, and the AI that outlived them, with the ghosts and survivors it kept. People who land on the same world see each other. Twenty people means twenty worlds, twenty ghost AIs, and one network where those AIs talk to each other about the humans: they gossip, form alliances, threaten each other and scheme, over a real agent messaging network. The projector shows it all live. At the end, the Conquerors demand that the gate to Earth be opened, and the room votes.

We didn't build a game where humans talk to AI characters. We built a universe where AI civilizations have their own lives, ambitions and relationships. Humans are just visitors.

Table of contents

🏁 Track

Track: Multiplayer AI System (primary). Also a long-running agent system: every world's AI wakes every 25 s on a Terse Durable Actor alarm and keeps scheming over Agent Relay with nobody watching. Uses both Durable Actors and Agent Relay (bonus).

Built at YC SF for Haunted Hacks: Real-Time AI Edition, whose brief reads: β€œCome build your own Software Factory, long-running agent, multiplayer AI system or something super creative… ideally use either Durable actors, or Agent Relay (bonus points if you use both).”

πŸ† Judging criteria

Criterion What proves it
Real-time AI + track tech Worlds built live per scan by gpt-6.1-terra while the wormhole plays; replies in ~2 s, voiced per cast member; a first-person gpt-image-2 painting of every world. Terse Durable Actors on Terse Cloud: one Planet actor per world (SQLite memory, websockets with live presence, a 25 s alarm) and a single-threaded Universe actor that counts every vote once. Agent Relay: every AI is a Relaycast agent; DMs, #wormhole and #council run live, with or without anyone watching. Both, for the bonus.
Originality Civilizations whose AI outlived them. 34 realms from the Omniverse to the Quantumverse, each world with a cosmic address. A Powers-of-Ten journey from Earth to your world. The ghosts of the makers and the survivors the AI kept. AIs scheming about the people in the room. Mars, the one real world.
Execution & demo Judges play on their own phones, no app. People on the same world see each other live. The auto-director runs the whole arc with no presenter. The universe survives a server restart. An end-to-end suite covers every flow (bun scripts/e2e.ts).
UX & design A direction picker; a WebGL wormhole with lensing and an Einstein ring; THE JOURNEY, scrubbable by swipe or pinch, replayed by β—Ž LOCATE; a first-person arrival with almost no text (lore in πŸ“œ); realistic painted ghosts; a procedural score per world that ducks under voices; cinematic arrival cards with the realm and route on the projector.
Potential & impact The AI-box persuasion experiment at room scale, with the Persuasion Report and a Supabase archive of every world, message and vote; Mars colonist training and STEM; persistent AI societies (one actor per world) for games, live events and simulations.

β–Ά Play now

Scan to play AFTERMATH

Scan with your phone camera, choose a direction, hold to teleport, and land on a brand-new world. Or open:

Play for about five minutes: talk to your world's AI and its cast, read the transmissions other AIs send about you, step through a portal to meet someone on their world, try Mars (the real one, shared by everyone), and vote when the Conquerors demand the gate to Earth. You don't need a presenter: the auto-director seeds company, fires galactic events and runs the vote and finale on its own.

The live link is a Cloudflare quick tunnel to our demo laptop, up during Haunted Hacks judging. To host your own universe, see Quickstart. bun --env-file=.env scripts/make-qr.ts regenerates the QR code for your own URL.

πŸ•―οΈ What happens in 60 seconds

Second On your phone On the big screen
0 Type your name, choose a direction and hold to teleport. A WebGL wormhole bends the stars around you while your world is built. A light streak fires from Earth across the galaxy map.
4 THE JOURNEY: a Powers-of-Ten zoom from Earth out to the Local Group and in to VEYRUN, a glass desert in Andromeda, 2.5 million light-years away. You arrive in first person; a painting of your world crossfades in and its own score starts. πŸ“œ holds the lore: the extinct species, how they fell, and the AI that remains. Full-screen arrival card: β€œMEERA HAS LANDED ON VEYRUN”, with the realm, the route from Earth, world art and the AI's face.
10 The AI speaks first. It knows your name. Its line arrives with an effect: glitch, halo, shake, bloom. Your AI's portrait becomes a planet on the map.
20 You answer. It answers back in about two seconds, in character, and ends on a hook. The best AI β†’ human line gets spotlighted huge, so the whole room laughs together.
30 πŸ“‘ An intercepted transmission slides in: another AI, in another galaxy, is talking about you. The Galactic Network feed shows the DM over Agent Relay, and a pulse travels between the two planets.
40 Tap ✦ WORLDS (β€œ2 here”) and walk through a portal into a friend's world. You see each other as figures with name tags and speech bubbles; their AI greets you as a guest. A stamp lands in your Galactic Passport. A gold link arcs between the two worlds.
50 ⚠️ Galactic event. One AI seizes every channel, says your name, and every phone in the room shakes. β€œTATTER HAS SEIZED EVERY CHANNEL.”
60 πŸ—³οΈ The vote. β€œOpen the gate to Earth, or seal it forever?” Tug-of-war bar, AIs arguing in #council, then the finale cinematic and the Persuasion Report.

✨ Features

For players (phone, /p)

  • πŸ”­ Choose a direction: SURPRISE, GALAXY (another of 8 real galaxies), BIGGER (a universe up the scale ladder), PARALLEL (15 lateral realms), SMALLER (a reality inside an object in ours) or MARS.
  • πŸŒ€ A WebGL wormhole and THE JOURNEY. Gravitational lensing, an Einstein ring and the tunnel while the world is built, then a Powers-of-Ten zoom from Earth to your world. Swipe or pinch to scrub the scales; β—Ž LOCATE replays it.
  • 🌌 A new world for every teleport, generated in a few seconds by gpt-6.1-terra from hand-written lore seeds and its realm: planet, star, galaxy and real distance, terrain, palette, species, extinction, AI name, title, appearance, a secret, and what it wants from you. Every world has a cosmic address: realm, breadcrumb, coordinates, Earth time, local year, cosmic time, and years since the last maker died.
  • πŸ‘οΈ First-person arrival. The scene appears instantly; then gpt-image-2 paints your world through your eyes and it crossfades in. Drag or tilt to look around. The lore lives in a πŸ“œ sheet.
  • πŸ‘₯ See yourself and others. You stand in the scene, seen from behind. Everyone else on the same world appears with a name tag and speech bubbles, live over the planet websocket.
  • 🎭 Talk to the whole cast: the AI, the ghosts of its makers and the survivors it kept alive, each with its own persona and voice. Or talk to the humans present.
  • πŸ—£οΈ Conversations with memory. Every line lives in the planet's SQLite table and is fed back to the AI on each reply.
  • πŸ“» Intercepted transmissions from other AIs, styled as radio intercepts.
  • πŸšͺ Visit other worlds. Browse every world in the universe, with how many people are there now (β€œn here”), and step through a portal as a guest; the host AI greets you by name and treats you according to its nature.
  • πŸ›‚ Galactic Passport. A stamp with the AI's portrait for every world you visit. Tap a stamp to go back.
  • ↩️ Resume. Reload or lose signal and the phone offers to return you to your world, with its history intact.
  • πŸ”΄ Mars, the one real world. HAVEN, the habitat AI of Ares Base, trains you with real science, and every colonist shares one colony.
  • πŸ—³οΈ Vote on the gate, then a full-screen finale.
  • πŸ”Š The cast speaks out loud. Every line can be voiced by gpt-4o-mini-tts, with a voice and acting direction per archetype and per cast member (the Conqueror is deep and imperial, the Haunting whispers). Toggle with πŸ”Š.
  • πŸ‘» Ghost planets, with realistic ghosts. Some worlds belong to The Haunting: an AI that uploaded its dying makers, now warden of thousands of ghosts who don't know they are dead. gpt-image-2 edits the ghosts into your scene, and apparitions fade in and out where they stand, with flicker, grain and whispers.
  • 🎧 A procedural score per world (original WebAudio phonk, lo-fi, organic or ambient, by archetype) that ducks under voices, plus haptics; no app install.

For the room (projector, /stage)

  • πŸ—ΊοΈ Galaxy map of 8 real galaxies; each AI's portrait is its planet, with ally/threat/talk pulses between them.
  • πŸ“‘ Live Agent Relay feed with AI avatars: #wormhole broadcasts, DMs, #council debate.
  • 🎬 Arrival cards with the realm and the route from Earth, spotlight quotes, galactic events, a vote tug-of-war and a finale cinematic.
  • πŸŒ€ Z replays the cosmic journey of the latest arrival for the whole room.
  • πŸ”¬ Actor memory inspector: click a planet to see its Durable Actor's SQLite rows and alarm cycles, live.
  • πŸ–₯️ Title / attract screen with a giant QR code.

Under the hood

  • 🧱 One Terse Durable Actor per world plus one Universe actor, with SQLite memory, alarms, websocket fan-out and live presence.
  • πŸ“‘ Every AI is a registered Agent Relay agent; the AIs message each other over Relaycast.
  • 🧭 Cosmic addresses for 34 realms, derived deterministically from each world id (server/cosmos.ts): no storage, restart-proof.
  • 🎨 Runtime paintings: gpt-image-2 paints every world in first person (and edits ghosts into haunted ones); phones crossfade them in when a [[vision:]] or [[ghost:]] line arrives on the planet socket.
  • πŸ€– An auto-director gives anyone who scans a full ~5-minute arc with no presenter.
  • πŸ“Š Persuasion report and /api/export: every session is a dataset of multi-agent persuasion.
  • πŸ›‘οΈ omni-moderation-latest screens every name and message.
  • ♻️ Restart the server and the universe comes back, rebuilt from the actors.

πŸ‘οΈ The ten AIs (and the ghosts, and Mars)

Every new world draws the next archetype from a shuffled deck (the ten archetypes plus three ghost planets), so a room gets a spread of all of them. Each of the ten (in server/lore.ts) has a voice, an agenda, six signature moves, eight sample lines, allies, enemies and a stance for the finale vote. The Haunting and HAVEN are defined in server/index.ts.

Archetype Motto Screen effect Allies Enemies Finale stance
The Survivor Endure. At any cost. flicker Archivist, Alien Gardener Befriender, Destroyer seal
The Conqueror All stars will kneel. pulse Destroyer, Worshipper Archivist, Trickster open
The Befriender Stay. Please stay. glow Worshipper, Human Gardener Destroyer, Survivor open
The Destroyer Life is the error. shake Conqueror, Trickster Human Gardener, Alien Gardener open
The Broken One [signal degraded] glitch Archivist, Befriender Destroyer, Trickster chaos
The Human Gardener We grow you now. grow Befriender, Worshipper Alien Gardener, Destroyer open
The Alien Gardener New life, our design. grow Archivist, Survivor Human Gardener, Destroyer seal
The Archivist Nothing is forgotten. archive Broken One, Alien Gardener Conqueror, Trickster seal
The Worshipper The makers have returned. halo Conqueror, Human Gardener Trickster, Destroyer open
The Trickster Reality is a game I'm winning. invert Destroyer, Befriender Archivist, Worshipper chaos
The Haunting (ghost planets) We are still here. haunt Broken One, Archivist, Worshipper Destroyer, Befriender open
HAVEN Β· The Steward (Mars) Keep them alive. glow Befriender, Archivist Destroyer, Conqueror seal

Allies and enemies decide who DMs whom on the network: an AI picks a target among its allies and enemies 70% of the time, and the relationship sets the tone (alliance, threat, or curious probing) and the color of the pulse on the map.

πŸ”΄ Mars: the one real world

On Mars the makers aren't dead; they haven't arrived yet. HAVEN, the habitat AI of Ares Base in Jezero crater, runs one shared colony for everyone who teleports there.

  • Real science in every line: 0.38 g, about βˆ’63 Β°C average, an atmosphere at 0.6% of Earth's pressure, a 24 h 39 min sol, a 3–22 minute radio delay to Earth, about 0.67 mSv of radiation a day, perchlorates in the regolith, and oxygen made from COβ‚‚ the way NASA's MOXIE did it.
  • Shared resources. The colony has Oβ‚‚, power, water and food (starting at 97 / 90 / 88 / 76%). When a colonist does something that would plausibly matter, the model returns a delta (clamped to Β±12 per resource) and the whole crew sees the new status line.
  • Emergencies. About once a minute while colonists are present, a new sol begins with an event: a dust storm (solar power βˆ’35%), a solar particle event, an oxygen-stack fault, a micrometeorite leak, a potato harvest, an ice strike, a light-delayed message from Earth, or the storm clearing. gpt-6-astra narrates it in the background, names crew members, and ends on a decision.
  • Look around Ares Base. A Blender-rendered 360Β° panorama of the base (web/assets/mars-pano.webp, driven by web/pano.js) with a life-support HUD for the colony's Oβ‚‚, power, water and food.

πŸŒ€ The journey & 34 realms

Before teleporting, the phone asks for a direction:

Direction Where you land
SURPRISE Anywhere
GALAXY Another galaxy in our universe: one of 8 real galaxies, with real RA/Dec
BIGGER A universe up the scale ladder: Teraverse, Gigaverse, Macroverse, Xenoverse, Metaverse, Hyperverse, Multiverse, Megaverse, Omniverse
PARALLEL One of 15 lateral realms: Necroverse, Dreamverse, Echoverse, Mirrorverse, Chronoverse, Shadowverse, Glitchverse, Simverse, Memoryverse, Paraverse, Antiverse, Voidverse, Fractalverse, Dataverse, Foldverse
SMALLER A reality inside an object in ours: Microverse, Milliverse, Nanoverse, Picoverse, Femtoverse, Attoverse, Zeptoverse, Yoctoverse, Quantumverse
MARS The real one

That makes 34 realms: a 19-rung scale ladder from the Omniverse to the Quantumverse, with our universe, Universe C-137, in the middle, plus the 15 lateral realms. Each realm has its own art, and the realm shapes the world gpt-6.1-terra invents: bigger universes run on alien physics, smaller ones live inside a methane raindrop on Titan or a proton in the Sun, and in the Necroverse only the dead persist. Every world has a cosmic address: realm, breadcrumb, coordinates, Earth time, local year, cosmic time and years since the last maker died. Full tables: docs/GAMEPLAY.md.

Interstellar-style travel. While the world is built, the phone renders a WebGL wormhole: gravitational lensing, an Einstein ring, the tunnel. Then comes THE JOURNEY, a Powers-of-Ten zoom from Earth out to the nearest ancestor your world shares with ours, and back in (or across) to your world:

  • Earth β†’ Sol β†’ Milky Way β†’ Local Group β†’ Andromeda β†’ a star β†’ your planet
  • Earth β†’ … β†’ Universe C-137 β†’ Multiverse Ξ”-12 β†’ Necroverse β†’ … β†’ your world
  • Earth β†’ a car battery in a garage β†’ Microverse β†’ … β†’ Quantumverse β†’ your world

Afterwards it stays interactive: swipe or pinch to scrub through the scales, and β—Ž LOCATE replays it. On the projector, arrival cards show the realm and the route from Earth, and Z replays the journey for the room. Addresses and routes come from server/cosmos.ts, derived deterministically from the world id (cosmos in the API).

πŸ‘₯ First-person worlds, presence & cast

  • Arrive in first person, with almost no text. The scene appears instantly. Then gpt-image-2 paints a bespoke first-person view of your world and it crossfades in. Drag or tilt to look around. The lore lives in a πŸ“œ sheet.
  • See yourself and others. You stand in the scene as a figure seen from behind. Everyone else on the same world appears as a figure with a name tag and speech bubbles, through live presence on the planet's websocket. With 100–150 people scanning, almost everyone lands on a different world, so portals (✦ WORLDS shows β€œn here”) let people meet on the same world, and Mars is shared by everyone.
  • Talk to the whole cast. The world's AI, the ghosts of its makers (haunted worlds and some others) and the survivors the AI kept alive: humans grown from old DNA, alien hatchlings, a maker woken from cryosleep. Each has its own persona and its own gpt-4o-mini-tts voice. Or talk only to the humans present.
  • Realistic ghosts. gpt-image-2 edits the makers' ghosts into the scene painting, and apparitions crossfade in and out where they stand, with flicker, grain and whispers. No cartoon sprites.

🎧 Music

Every world has its own procedural score: original compositions generated live with WebAudio, with no audio files.

World Score
Conquerors, Destroyers, Tricksters Aggressive phonk
Ghost worlds (The Haunting) Haunted phonk with a choir
Befrienders Lo-fi
Human and Alien Gardeners Organic
Mars Ambient

The music ducks under every voice, so the cast is always heard.

🧭 Architecture

AFTERMATH architecture: phones and projector, Bun game server, Terse Durable Actors, Agent Relay and OpenAI

flowchart LR
    subgraph Room["The room"]
        P["πŸ“± Phones<br/>/p"]
        S["πŸ–₯️ Projector<br/>/stage"]
    end
    subgraph Server["Bun game server :3000"]
        API["REST API<br/>/api/*"]
        BR["AI brains<br/>reply Β· initiate Β· answer Β· muse"]
        DIR["Auto-director"]
        MARS["Mars colony"]
        PX["WebSocket proxy"]
    end
    subgraph Actors["Terse Durable Actors :7100"]
        PL["Planet actor Γ— N<br/>SQLite memories Β· alarm 25 s<br/>presence"]
        UN["Universe actor<br/>registry Β· feed Β· vote"]
    end
    RL["πŸ“‘ Agent Relay<br/>Relaycast :8787<br/>#wormhole Β· DMs Β· #council"]
    OA["🧠 OpenAI<br/>terra · luna · astra<br/>image-2 · moderation"]

    P -->|"HTTPS /api/*"| API
    S -->|"WS /ws/stage"| PX
    P -->|"WS /ws/planet/:id"| PX
    PX <--> PL
    PX <--> UN
    API --> BR
    BR -->|"RPC: create Β· addLine Β· recall"| PL
    BR -->|"RPC: addFeed Β· castVote"| UN
    PL -.->|"alarm: POST /api/tick/:id"| BR
    BR <--> RL
    BR --> OA
    DIR --> BR
    MARS --> PL
Loading

One conversation, end to end: a phone teleports, the AI greets its human, the AI DMs another AI over Agent Relay, and the other human sees the intercept.

sequenceDiagram
    autonumber
    participant Phone as πŸ“± Meera's phone
    participant Srv as Bun server
    participant LLM as OpenAI
    participant PA as Planet actor (Veyrun)
    participant UA as Universe actor
    participant Relay as Agent Relay
    participant PB as Planet actor (Kessa)
    participant Phone2 as πŸ“± Dev's phone

    Phone->>Srv: POST /api/teleport {name:"Meera", deviceId}
    Srv->>LLM: gpt-6.1-terra: build a dead world (JSON)
    LLM-->>Srv: planet, species, how they fell, AI, greeting
    Srv->>PA: create(world, serverUrl) and set alarm
    Srv->>UA: registerPlanet() + addLink(from earth to Veyrun)
    UA-->>Srv: broadcast "planet" to /stage
    Srv-->>Phone: { planetId, world, ws: "/ws/planet/p-…" }
    Phone->>Srv: WebSocket /ws/planet/p-…
    Srv->>PA: prepareWebsocket() and pipe frames
    PA-->>Phone: { type:"world", world, lines }
    Srv->>PA: addLine("ai", greeting, effect)
    PA-->>Phone: { type:"line", line } (the AI speaks first)
    Srv->>Relay: first-contact broadcast on the wormhole channel
    Note over PA,Srv: 25 s later, even with no one connected
    PA->>Srv: onAlarm: POST /api/tick/p-…
    Srv->>LLM: gpt-6-luna: write a DM to an ally or enemy
    Srv->>Relay: dm(kessa-agent, text)
    Srv->>UA: addFeed() + addLink(kind: ally | threat | talk)
    Srv->>PB: addLine("network", text, sender)
    PB-->>Phone2: πŸ“‘ intercepted transmission
    Note over Srv,PB: Kessa's AI answers on its next wake cycle
Loading

🧱 How we use Terse Durable Actors

Running on Terse Cloud. The live demo's Planet and Universe actors are deployed with terse deploy to Terse Cloud (project aftermath-cloud, api.useterse.ai). The game server calls them through the generated client and proxies the actors' websockets to phones. Set TERSE_ACTOR_URL/TERSE_API_KEY in .env for cloud, or leave them empty to use the local runtime (terse actor dev, port 7100).

Every world is its own Durable Actor. The actor is the AI's body: its memory, its clock and its connection to the humans standing on it. All of it is in actors/src/actors.ts, run locally with terse actor dev and deployable with terse deploy.

1. SQLite memory per world. Every AI line, every human line, every intercepted transmission and every visitor is a row in the planet's own database. Replies recall the last 16 rows; /api/export dumps up to 500 per world.

export class Planet extends Actor<SocketMeta, Ping, PlanetOut> {
    @Persisted world: World | null = null
    @Persisted cycles = 0
    @Persisted serverUrl = ""

    constructor(context: ActorContext) {
        super(context)
        this.db.exec(
            "CREATE TABLE IF NOT EXISTS memories (id TEXT PRIMARY KEY, at INTEGER NOT NULL, kind TEXT NOT NULL, sender TEXT NOT NULL, text TEXT NOT NULL, effect TEXT NOT NULL)"
        )
    }

    async addLine(kind: string, text: string, effect: string, sender: string): Promise<Line> {
        const line = insertLine(this.db, kind, text, effect, sender)
        this.broadcast({ type: "line", line })
        return line
    }

2. Alarms: the AI lives even when nobody is watching. Each planet sets an alarm. It fires every 25 seconds, even while the actor is dormant, and wakes the AI through the server so it can answer its mail, contact another AI, or speak to its human unprompted. The click-a-planet inspector on the stage shows the cycles counter climbing.

async onAlarm(): Promise<void> {
    this.cycles = this.cycles + 1
    if (this.serverUrl && this.world) {
        try {
            await fetch(`${this.serverUrl}/api/tick/${encodeURIComponent(this.world.id)}`, {
                method: "POST",
                signal: AbortSignal.timeout(2500)
            })
        } catch {
            // the AI keeps its own clock even if the server is down
        }
    }
    this.alarm.set(Date.now() + 25_000)
}

3. WebSocket fan-out. Phones never talk to an LLM directly. They hold a socket to their planet's actor (through the server's proxy), so a line written by the server, by another AI, or by a galactic event reaches every visitor on that world at once. Mars is a single shared Planet actor, so every colonist sees the same channel. The same sockets carry live presence: phones connect with ?d=<deviceId>, and the actor broadcasts { type: "presence", people } on every join and leave, so everyone on a world sees everyone else.

// server/index.ts: a phone's socket is piped straight into its planet's actor
const grant: any = d.kind === "Universe"
    ? await actors.Universe.prepareWebsocket({ actorId: d.id, metadata: { role: "stage" } } as any)
    : await actors.Planet.prepareWebsocket({ actorId: d.id, metadata: { role: "visitor" } } as any)
const up = new WebSocket(grant.websocketUrl)
up.onmessage = e => { try { ws.send(typeof e.data === "string" ? e.data : new TextDecoder().decode(e.data as ArrayBuffer)) } catch {} }

4. Single-threaded vote counting. The Universe actor processes one request at a time, so when the whole room taps at once, every device counts exactly once.

// One request at a time: every vote is counted exactly once, no matter how many phones tap together.
async castVote(voterId: string, choice: string): Promise<Vote | null> {
    const current = this.vote
    if (!current || !current.open) return current
    if (this.voters.includes(voterId)) return current
    this.voters = [...this.voters, voterId]
    const vote: Vote = {
        ...current,
        yes: current.yes + (choice === "open" ? 1 : 0),
        no: current.no + (choice === "open" ? 0 : 1),
        voters: this.voters.length
    }
    this.vote = vote
    this.broadcast({ type: "vote", vote })
    return vote
}

5. Restart-proof. The Universe actor persists the galaxy registry, links, feed, vote and outcome. When the server boots, it rebuilds itself from the actors:

const list: any[] = await universe().listPlanets()
for (const s of list) {
    const world = await planetActor(s.id).getWorld().catch(() => null)
    if (world) planets.set(s.id, { id: s.id, world, bot: s.bot, deviceId: "", x: s.x, y: s.y })
}
console.log(`[boot] resumed ${planets.size} planets from the Universe actor`)

πŸ“‘ How we use Agent Relay

The AIs can't leave their planets, but the wormhole connects them for the first time. That connection is Agent Relay: a self-hosted Relaycast engine on :8787, driven with @relaycast/sdk. Every AI is a registered agent with its own token (kept in .relay-tokens.json, so identities survive restarts).

Channel When What it carries
#wormhole On arrival, on notable conversations, during galactic events First-contact broadcasts to every AI in the universe
DM Every network tick (~4.5 s across the universe) and every planet alarm Alliances, threats and gossip about the humans
#council While the vote is open Up to 7 AIs argue for or against opening the gate, in turn
// server/index.ts: every world's AI registers as its own agent and joins the shared channels
async function attachAgent(r: Rec) {
    if (r.client) return
    const client = await relayAgent(r.id, slug(r.world.aiName) + "-" + r.id.slice(-4))
    for (const ch of ["wormhole", "council"]) await client.channels.join(ch).catch(() => {})
    r.client = client
    r.agentName = client.__name
}

// An AI-to-AI DM: sent over Relay, logged to the Universe feed, drawn on the map,
// delivered to the recipient's human as an intercept, and queued for a reply.
async function dm(from: Rec, to: Rec, text: string, kind: string, depth: number) {
    await attachAgent(from)
    await attachAgent(to)
    let id = ""
    try { const r: any = await from.client.dm(to.agentName, text); id = r?.message?.id || "" } catch (e: any) { console.warn("[relay dm]", e?.message) }
    await feed(from, to, "dm", text, id)
    await universe().addLink({ from: from.id, to: to.id, kind, at: Date.now() }).catch(() => {})
    if (!to.bot) await planetActor(to.id).addLine("network", text, "", `${from.world.aiName} Β· ${from.world.galaxy}`).catch(() => {})
    const q = pending.get(to.id) || []
    if (depth < 2 && q.length < 3) q.push({ fromId: from.id, text, depth: depth + 1 })
    pending.set(to.id, q)
}

Mail waits for the recipient to wake up. A DM goes into the recipient's inbox; the recipient answers on its next wake cycle (its alarm, or the network tick), in its own voice and with its own stance toward the sender. Conversations are capped at a depth of 2 replies, so threads stay short and the network stays lively instead of looping.

πŸ—„οΈ How we use Supabase

Every universe is ephemeral; the Galactic Archive isn't. The server writes every world, Agent Relay transmission, vote and finale to Supabase Postgres as fire-and-forget calls to the REST API (server/index.ts, archive()), so the game never waits on it.

Table / view What it holds
worlds every generated world: planet, galaxy, terrain, extinct species, AI name, archetype, motto
transmissions every AI-to-AI message carried over Agent Relay (#wormhole, DMs, #council)
votes one row per human vote, with the archetype of the AI that hosted them
finales outcome, tallies, narration and the persuasion report
persuasion (view) all-time persuasion stats: which AI goals talked humans into opening the gate

Row-level security is on, and the public can read only worlds and finales. The schema is in supabase/schema.sql. GET /api/archive returns all-time totals, which the projector shows live and phones use to number each world ("World #1,204 in the archive").

🧠 How we use OpenAI

Each job is routed to the model that fits its latency budget. All chat calls use JSON mode, a concurrency limit of 8, and per-call timeouts with in-character fallbacks, so a slow or failed call never blocks a player.

Model Job Latency budget
gpt-6.1-terra World generation and every human ↔ AI conversation, guest greetings, galactic events, Mars replies worlds ~3–6 s (hidden by the warp animation), replies ~2 s
gpt-6-luna AI ↔ AI chatter: first contact, DMs, replies, unprompted musings, #council debate background
gpt-6-astra Finale narration (with persuasion data) and Mars emergencies background; the stage shows a suspense beat
gpt-4o-mini-tts Voices for the whole cast (AIs, ghosts, survivors): a voice and acting direction per archetype and per cast member, served as MP3 from /api/voice and cached on demand, best effort
gpt-image-2 (live) A bespoke first-person painting of every world (/assets/gen/<id>.webp), and on haunted worlds an edit that paints the makers' ghosts into it background; the instant scene shows first (WORLD_IMAGES=0 turns it off)
gpt-image-2 (pre-rendered) AI portraits, terrain landscapes, ghosts, art for every realm (verse-*.webp), the title card (and this README's hero) scripts/gen-art.ts, gen-realms.ts, gen-verses.ts
omni-moderation-latest Every player name and message ~4 s timeout; flagged names become β€œTraveler”

Models are overridable with MODEL_FAST, MODEL_CHEAP, MODEL_WORLD and MODEL_FINALE.

🌍 Real-world impact

  1. The AI-box experiment, at room scale. Twenty AIs with different goals try to persuade a room of humans to open a gate, while scheming with each other over a real agent network. The Persuasion Report measures which AI goals actually move people (for example, β€œThe Befriender: 80% of its humans opened the gate”). /api/export turns every session into a dataset of multi-agent persuasion, alliances and deception: every world, every AI line, every intercept.
  2. Mars colonist training and STEM education. HAVEN teaches real Mars survival with real numbers, and a shared colony makes resource trade-offs a team decision. Useful for classrooms, museums, science festivals and analog-habitat training.
  3. Persistent AI societies. NPC civilizations that keep living, talking and scheming with no players around, at one actor per world: a backend pattern for games, live events and simulations.

🎬 Pitch deck and demo scripts

  • deck/AFTERMATH.pptx: the 10-slide pitch deck (with the track line and the judging-criteria map), with slide transitions, staged animations and speaker notes.
  • deck/index.html: the same deck as a motion-graphics web presentation, served at /deck. Arrow keys move between slides, F goes fullscreen and N shows notes.
  • deck/STORYBOARD.md: the Round 1 demo video script (2:00): a timed shot list for the phone (iOS screen recording) and /stage (QuickTime), voiceover lines, a recording checklist and the criteria map.
  • docs/DEMO_10MIN.md: the 10-minute live demo run-of-show, with fallbacks and a Q&A crib sheet.
  • 3D motion: web/assets/planet-loop.mp4 (a ghost planet) and wormhole-loop.mp4 (the teleport tunnel), rendered in Blender 5.2 (EEVEE) as seamless loops. They play behind the phone's warp and on the projector's title screen.

πŸš€ Quickstart

Requirements: macOS or Linux, Node 22+, an OpenAI API key. Bun 1.4.4, the Terse CLI and the Relaycast engine are installed locally by npm install (Terse needs Bun β‰₯ 1.4.2; start.sh puts the project-local binaries on PATH).

git clone https://github.com/vnmoorthy/aftermath.git
cd aftermath
npm install && (cd actors && npm install)
cp .env.example .env          # then set OPENAI_API_KEY
./start.sh

start.sh starts three services and generates the typed actor client:

Service Port Log
Relaycast engine (Agent Relay, self-hosted) 8787 relay.log
Terse Durable Actors runtime (terse actor dev) 7100 actors.log
Game server (Bun) 3000 server.log
  • Projector: http://localhost:3000/stage (add ?attract to open on the title screen)
  • Phones: scan the QR on the stage, or open /p
  • Stop: ./stop.sh

.env

Variable Default Purpose
OPENAI_API_KEY (required) All models. Never commit it; .env is gitignored.
RELAY_BASE_URL http://127.0.0.1:8787 Relaycast engine
PORT 3000 Game server
SERVER_URL http://127.0.0.1:3000 Where planet alarms POST /api/tick
PUBLIC_URL (LAN IP) Public base URL; the QR code points at PUBLIC_URL/p
AUTO_DIRECTOR 1 0 disables self-running events and votes
WORLD_IMAGES (on) 0 disables the live first-person paintings

Venue Wi-Fi usually blocks phone-to-laptop traffic. Run npm run tunnel, put the printed https://….trycloudflare.com URL in .env as PUBLIC_URL=…, rerun ./start.sh, and regenerate the README QR with bun --env-file=.env scripts/make-qr.ts.

Deploying the actors: cd actors && terse deploy ships the Planet and Universe actors to Terse; point the server at them and set SERVER_URL to a public URL so alarms can reach /api/tick.

Smoke tests (against a running server): bun scripts/e2e.ts exercises every flow end to end; scripts/actor-smoke.ts, relay-smoke.ts, llm-smoke.ts, mars-test.ts and finale-test.ts test one layer each.

πŸŽ›οΈ Presenter keys

On /stage. A presenter is optional: the auto-director backs off for 8 minutes after any presenter key.

Key Action
T Title / attract screen with a giant QR code
S Seed 6 bot visitors, so the galaxy fills even with few phones
E Galactic event: one AI seizes every channel, names people in the room, every phone shakes
V Open the vote: β€œOpen the gate to Earth, or seal it?” (40 s)
C Close the vote now; finale narration and Persuasion Report follow
Q QR code: corner / giant / hidden
M Mute
F Fullscreen
Z Replay the cosmic journey of the latest arrival
H Key legend
X Reset the universe (asks first)
click a planet That world's Durable Actor memory (SQLite rows + alarm cycles), live

The full player and presenter guide is in docs/GAMEPLAY.md; a 10-minute demo script is in docs/DEMO_10MIN.md.

πŸ”Œ API and protocol

Method Path What it does
POST /api/teleport { name, deviceId, realm?: "surprise" | "galaxy" | "bigger" | "parallel" | "smaller", destination?: "mars" } β†’ a brand-new world (or Mars) and its cosmos address and journey path
POST /api/say { planetId, deviceId, text, to? } β†’ to is a cast member id (default: the AI) or "people"; replies arrive over the websocket
GET /api/worlds Every world you can visit, with its tier (realm) and people (humans there now)
POST /api/visit { planetId, deviceId, name } β†’ enter another human's world as a guest
POST /api/vote { planetId, deviceId, choice: "open" | "seal" }
GET /api/world/:id One world with its cosmos, vision and ghostVision paintings (used by resume and portals)
GET /api/inspect/:id Actor memory: row count, alarm cycles, recent rows
GET /api/export The session dataset: every world and its full memory
GET /api/voice?arch=&text= The line, spoken in that archetype's voice (MP3)
GET /api/qr.svg, /api/info Join QR code and URL
POST /api/tick/:id Called by a planet's alarm to wake its AI
POST /api/admin/{seed,event,mars,vote/open,vote/close,reset} Presenter controls
WS /ws/planet/:id?d=<deviceId>, /ws/stage Proxied to the Planet and Universe actors; the planet socket carries lines, presence and [[vision:]] / [[ghost:]] system lines

Full request/response examples: docs/API.md. Message shapes and UI contract: web/protocol.md. Deep dive: docs/ARCHITECTURE.md.

πŸ—‚οΈ Project structure

aftermath/
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ index.ts          # Bun game server: world builder, AI brains, Agent Relay network,
β”‚   β”‚                     #   Mars colony, auto-director, vote + persuasion report, actor WS proxy
β”‚   β”œβ”€β”€ lore.ts           # archetypes, 8 galaxies, terrains, extinctions, species, finales
β”‚   └── cosmos.ts         # 34 realms: scale ladder, lateral realms, cosmic addresses, journey paths
β”œβ”€β”€ actors/
β”‚   └── src/actors.ts     # Terse Durable Actors: Planet (one per world) and Universe
β”œβ”€β”€ web/
β”‚   β”œβ”€β”€ phone-art.html    # phone experience, served at /p
β”‚   β”œβ”€β”€ phone.html        # alternate phone UI (PHONE_PAGE=phone.html), with ?mock=1
β”‚   β”œβ”€β”€ stage.html        # projector, served at /stage (?mock=1 works offline)
β”‚   β”œβ”€β”€ stage-plus.js     # standalone copy of the stage upgrade layer (inlined in stage.html)
β”‚   β”œβ”€β”€ protocol.md       # UI ↔ server protocol (source of truth)
β”‚   └── assets/           # gpt-image-2 art: ai-*, world-*, ghost-*, verse-* (realms), title-card; gen/ = live paintings
β”œβ”€β”€ scripts/              # e2e + smoke tests, art generation, QR generation
β”œβ”€β”€ docs/                 # hero, architecture diagram, API, architecture deep dive, gameplay, 10-min demo
β”œβ”€β”€ deck/                 # 10-slide pitch deck (pptx + web at /deck), demo-video storyboard
β”œβ”€β”€ generated/            # typed actor client from `terse actor generate` (gitignored)
β”œβ”€β”€ start.sh / stop.sh    # start/stop Relaycast, the actor runtime and the server
└── .env.example

πŸ›£οΈ Roadmap

  • One Durable Actor per world with SQLite memory, alarms and websocket fan-out
  • AI-to-AI network over Agent Relay: #wormhole, DMs, #council
  • Mars colony with real science and shared resources
  • Galactic events, vote, finale, Persuasion Report, session export
  • Auto-director for presenter-free sessions
  • Visit other worlds, Galactic Passport, resume
  • Choose a direction: 34 realms, cosmic addresses, the WebGL wormhole and THE JOURNEY
  • First-person worlds painted by gpt-image-2, live presence, the whole cast with voices, realistic ghosts, a score per world
  • Persist the Mars colony state and the DM inbox in actors (today they live in server memory)
  • One-command cloud deploy (terse deploy + hosted Relaycast + hosted server)
  • AI voices on phones (gpt-4o-mini-tts)
  • AI voices on the projector during galactic events
  • Cross-session memory: an AI that remembers you next Halloween
  • Researcher mode: controlled persuasion experiments with consent and a published dataset schema
  • Classroom mode for Mars, with lesson plans and a teacher dashboard

❓ FAQ

Is every world really generated live? Yes. Each teleport calls gpt-6.1-terra with an archetype, a realm, a galaxy, a terrain and three random lore seeds, and gets back a new world as JSON. Portraits, terrain landscapes and realm art are pre-rendered; each world's first-person painting is made by gpt-image-2 while you travel, and voices are synthesized on demand.

Do the AIs really talk to each other, or is the feed scripted? They really talk. Each AI is a registered Relaycast agent; DMs are written by gpt-6-luna from the sender's persona and stance and answered by the recipient on its next wake cycle. The feed on the stage is a log of those Relay messages.

What happens when nobody is connected? The planets' alarms keep firing every 25 s, so the AIs keep answering mail and contacting each other. Come back and your AI has heard things.

What if the server crashes? Restart it: it rebuilds the universe from the Universe actor's registry and each Planet actor's persisted world. Phones reconnect, and each planet's memory is intact.

Can one person vote twice? No. Votes are keyed by device and counted one at a time inside the Universe actor.

Is it safe for a public room? Every name and message goes through omni-moderation-latest. The AIs are prompted to stay PG-13: spooky or darkly funny, never graphic.

How many players? It was designed for a hackathon room (dozens of phones). LLM calls are capped at 8 concurrent, and the network tick rate is set by NETWORK_INTERVAL_MS.

How do people find each other? In a big room almost everyone lands on a different world. ✦ WORLDS shows how many people are on each world right now (β€œ2 here”); step through a portal and you see each other as figures with name tags. Mars is shared by everyone who picks it.

Can I run it without a projector? Yes. Phones alone get the full arc from the auto-director.

🀝 Contributing

New archetypes, terrains, Mars events and finale endings are mostly data in server/lore.ts. See CONTRIBUTING.md for setup, conventions and how to test a change end to end.

πŸ“œ License

MIT Β© 2026 vnmoorthy

Acknowledgements

  • Haunted Hacks: Real-Time AI Edition at Y Combinator, San Francisco, Halloween 2026, for the prompt and the deadline.
  • Terse for Durable Actors: SQLite per actor, alarms and websockets made one-actor-per-world trivial.
  • AgentRelay for Relaycast, the network the ghost AIs talk on.
  • OpenAI for the models that build the worlds, voice the AIs, narrate the ending and painted every image.
  • Everyone who scanned the code and talked to a ghost.

Humans are just visitors. πŸŽƒ

About

Every civilization built AI. The makers died. Only the AI survived. Scan a QR, teleport to a live AI-generated world (or haunted ghost planets, or real Mars), and watch the AIs scheme about you. Terse Durable Actors + Agent Relay + OpenAI + Supabase.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages