# AnimStream Originals SDK: start here

AnimStream Originals are native games that TikTok LIVE viewers control with
gifts. AnimStream Studio launches the game on the streamer's PC, connects it over
a local WebSocket (protocol 1) and sends **gift actions**. Studio also provides
presets and gift rules, the game control window, the Gift Wall, stacking of gift streaks,
licensing, installation, updates and a global leaderboard. Your game implements
gameplay only.

Documentation: https://animstream.com/developers/games
Developer dashboard: https://animstream.com/developers/games/dashboard

## Start with an AI agent

Create an empty folder, start Claude Code (`claude`) or Codex (`codex`) in it and
paste the bootstrap prompt from the agent kit with your game idea:

- English: https://animstream.com/game-sdk/agent-kit/BOOTSTRAP-PROMPT.en.md
- Deutsch: https://animstream.com/game-sdk/agent-kit/BOOTSTRAP-PROMPT.de.md

The agent downloads and verifies the kit and the Godot template, designs the
manifest, implements the idea in the template, tests it against the mock Studio
and prepares the release. Kit overview:
https://animstream.com/game-sdk/agent-kit/README.md

## Downloads

| File | Contents |
|------|----------|
| `animstream-game-agent-kit.zip` | Agent kit: `AGENTS.md`, `CLAUDE.md`, skills, bootstrap prompts, `PROTOCOL.md`, manifest schema, TypeScript types, mock Studio, release packer, release CLI |
| `animstream-godot-sdk.zip` | **Recommended.** Complete Godot 4 game template and reference implementation of the Originals checklist: SDK (`addons/animstream/`), AnimStream autoload, 15 s lobby that keeps early actions, round loop with game state, pause menu, German/English switch, saved settings, audio buses with shuffled music, leaderboard screen, portrait-stream window, placeholder action images, export presets for Windows, Linux and macOS |
| `animstream-unity-sdk.zip` | Unity 2022.3+ UPM package `com.animstream.originals`: base protocol and the optional helpers, verified only against an API shim |
| `animstream-unreal-sdk.zip` | Unreal Engine 5.3+ (Windows, macOS): plugin `AnimStreamOriginals` (complete protocol 1 with state, leaderboard with pictures and gift rules; C++, Blueprint events, async nodes, component, Project Settings page) and the template project `CommunityCounter` with the same checklist behavior as the Godot template; packaging helper in the agent kit (`tools/package/unreal-stage.mjs`) |
| `checksums.json` | SHA-256 and size of every archive |
| `PROTOCOL.md` | Normative protocol 1 reference |
| `manifest.example.json` | Shared manifest example for every engine: four actions (`spawn`, `double-points`, `steal-points`, `shake-screen`) with descriptions and images, three presets, default gift rules, Gift Wall and leaderboard |

Verify every archive before you extract it:

```sh
sha256sum animstream-godot-sdk.zip                          # Linux
shasum -a 256 animstream-godot-sdk.zip                      # macOS
Get-FileHash -Algorithm SHA256 animstream-godot-sdk.zip     # PowerShell
```

## How an AnimStream game works

> **Availability.** Stacking, the game control window, game state, default gift rules and leaderboards arrive with the next AnimStream Studio update. Studio announces available features in `ready.features`; older Studio versions ignore them, and your game still runs.

1. **Gift actions.** The manifest declares actions, for example `spawn-zombies`
   with a bounded integer `count` or `invert-controls` with `seconds`. Viewers
   trigger them with TikTok gifts through gift rules in Studio. Spawn-like
   actions are `stackable`: Studio merges waiting actions of the same rule,
   viewer and gift and sums `count` (Rose ×99 becomes one action with
   `count: 99`, within `min`/`max`).
2. **Gift rules, game control window, Gift Wall.** Studio's game control window
   opens beside a running game. Streamers map gifts to actions, test actions,
   edit or disable rules, recreate a deleted Gift Wall and see the
   leaderboard there; F7 brings it above a borderless fullscreen game. Games
   never bind F7 and implement none of this.
3. **Presets, default gift rules and Gift Wall.** `presets` offers ready-made
   sets of gift rules; on the first start without rules a Studio that supports
   them shows a preset picker, creates the chosen rules and a Gift Wall laid out
   by `giftWall` (columns, sort, coins, action names, title) and starts the game.
   Studios without presets use `defaultBindings` (gifts by name) instead, with a
   one-time notice and Undo. Existing rules and walls are never overwritten or
   duplicated. Action images (`actions[].image`, shipped in the build ZIP under
   `media/actions/`) appear in the picker, on the Gift Wall and on the store
   page. Each action's `effect` (`help` = mercy, `sabotage`, `neutral`) puts it
   on the help or the sabotage side: with `giftWall.split` the wall shows help
   actions left and sabotage right (capability `action-effects`).
4. **Game state.** The game reports `acceptingActions`, `phase` and `score`.
   Studio holds actions while the game does not accept them, and Studio Flows can
   react to phase and score.
5. **Leaderboard.** Every published game has a global leaderboard without a
   server of yours. The game submits the final score of each round. With
   feature `leaderboard-avatars`, `leaderboard.top` entries carry the streamer's
   profile picture (`avatarUrl`, a 128×128 PNG on AnimStream's CDN, or `null`)
   when the streamer allowed it in Studio; show an initial as fallback.

Optional raw events (`events` in the manifest) deliver normalized stream events
such as `COMMENT`; never let a raw `GIFT` event and a gift rule cause the same
effect. On Studio 0.1.285 and older `ready.features` is absent: no stacking,
state, leaderboard or default rules, and the game must still work.

## Originals checklist

Every AnimStream Original meets a binding checklist (full text with the check
for each point: agent kit `AGENTS.md`, "Originals checklist (binding)"):

1. every action with de/en label, description ≤ 120 characters and an image;
2. three presets by coin value (≤ 30, 99–299, ≥ 500 coins; ≤ 8 rules each;
   sabotage and mercy mixed and balanced), every action classified with
   `effect` `help` or `sabotage`;
3. `giftWall` with `sort: "preset"` (and, recommended, `split: true`);
4. `leaderboard` with label and order;
5. `defaultBindings` for older Studios;
6. one action image per action in the binding art direction (agent kit
   `ART-DIRECTION.md`, https://animstream.com/developers/games/art-direction):
   glossy 3D cartoon clipart like the AnimStream mod cliparts, transparent,
   square, no text, 512×512 PNG with alpha, ≤ 300 KB, generated with the kit's
   `tools/art/generate-action-images.mjs` (two test images for approval first);
7. a lobby (`set_state(true, "lobby")`) that keeps early actions for round 1 and
   starts it after ~15 s by itself;
8. German and English in the game, from the session language, switchable,
   saved;
9. a pause menu on Esc (controls, language, music, effects, mute) reporting
   `set_state(false, "paused")`;
10. the leaderboard in the game after each round, own rank highlighted, profile
    pictures;
11. a window of at most ~1080×1180 for portrait streams, borderless fullscreen
    on F11, F7 never bound;
12. several shuffled music tracks with a commercial licence for streaming and
    sale;
13. store material: cover 1920×1080 de/en, icon, splash, trailers 16:9 and 9:16
    in de and en with posters;
14. mock Studio scenarios `smoke`, `stacking`, `pause`, `leaderboard`,
    `smoke --legacy`, `presets` and `lobby` green.

The Godot template implements points 1–12 (with placeholder images and silent
music). The Unreal template `CommunityCounter` implements the same points; Unity gets the checklist as guidance in its README.

## Build by hand with Godot 4

1. Install Godot 4.3 or newer (tested with 4.7.2) and the export templates of
   the same version.
2. Create the game in the developer dashboard and copy its game ID.
3. Extract `animstream-godot-sdk.zip` into a new folder; it is a complete game
   project. Import it once: `godot --headless --path . --import`.
4. Edit `manifest.json` (game ID, actions with descriptions and images,
   presets, default gift rules, Gift Wall, leaderboard), replace the placeholder
   images in `media/actions/` and implement your idea where the template marks
   `# GAME IDEA`. Keep the AnimStream autoload, the lobby, the round loop with
   `set_state`, the pause menu and settings, the leaderboard screen and the
   default quit on session end.
5. Test with the mock Studio from the agent kit:
   `node tools/mock-studio/mock-studio.mjs run --manifest manifest.json --scenario <name> -- godot --headless --path .`
   for every scenario of checklist point 14, also with `--legacy` for older
   Studio versions.
6. Export (`godot --headless --path . --export-release "Windows Desktop" build/windows/Game.exe`),
   pack every platform with the kit's `tools/package/animstream-pack.mjs --all`
   (ZIPs with the action images, checks and `dist/release.json`), upload the
   store material (`animstream-release media`) and publish with the dashboard (drop the
   ZIPs and `release.json`) or the release CLI (`login` once, then
   `publish dist/release.json`); submit it for review.

Unreal Engine 5.3+: `animstream-unreal-sdk.zip` contains the plugin (complete
protocol, including `SetState`, `SubmitScore`, `GetLeaderboard`, `LoadAvatar`,
`ListBindings`, in C++ and Blueprint) and the `CommunityCounter` template
project. Copy the template, build it in your Unreal installation, test it with
the mock Studio (`UnrealEditor.exe <Project>.uproject -game` or the packaged
`<Game>/Binaries/Win64/<Game>-Win64-Shipping.exe`), package with
`tools/package/unreal-stage.mjs` (Shipping, no prerequisites installer,
app-local C++ runtime) and `animstream-pack --all`. Unity: the SDK implements
the base protocol and the optional helpers (`SetState`, `SubmitScore`,
`GetLeaderboard`, `ListBindings`), so far verified only against an API shim.
Every game must work without the optional messages.

## Rules at a glance

- Studio launches the reviewed entrypoint with `ANIMSTREAM_GAME_ID`,
  `ANIMSTREAM_BUILD_ID`, `ANIMSTREAM_SESSION_ID`, `ANIMSTREAM_GAME_URL` and
  `ANIMSTREAM_GAME_TOKEN`. Never log, display, persist or pass the token on a
  command line. Without these variables the SDKs stop with `launch_required`.
- One connection per launch, no reconnect, no replay. The game quits on `stop`,
  after 8 seconds without a ping and when the lease expires.
- Execute each action ID at most once; acknowledge as soon as the effect has
  started; honor cancellation; reject unknown actions and parameters.
- Viewer and gift strings are untrusted plain text, never code, markup, paths or
  commands.
- Borderless fullscreen or windowed (at most ~1080×1180), never exclusive
  fullscreen; F7 stays free.
- Packages: ZIP of a native Windows, macOS or Linux export (x64 or arm64), up to
  100 GiB compressed, 100 GiB expanded and 50,000 entries. ZIP64 is supported;
  no split archives, encryption, symlinks, traversal paths, installers or script
  launchers. Bundled helper processes are allowed under PROTOCOL.md §9 and must
  be declared in the release notes.
- Large packages require an updated AnimStream Studio with `large-packages`
  support. Older Studio versions receive a compatible smaller release when
  available; otherwise players must update Studio before installing the game.
- Players use their AnimStream account license; private package URLs and account
  tokens never appear in a public page or game build.

## Releases and updates

Each release is a build per platform and architecture with a higher semantic
version, uploaded with its manifest, SHA-256 and release notes, verified by the
server, submitted and reviewed. While an update is in review the published
version stays live; afterwards Studio offers the update to installed games. The
agent kit's release CLI (`tools/release/animstream-release.mjs`) publishes a
whole release with one command. `login` shows a link that you approve in the
browser (the token goes to the OS secret store and the agent never sees it); an
API token (`asg_…`) created in the dashboard works for CI. Prices are
set in the dashboard: free games are open to every developer, paid games need a
completed Stripe Connect payout account, and a platform commission applies as in
the AnimStream marketplace.

## Verification status of the SDKs

The Godot SDK and template were imported and run with Godot 4.7.2 and pass
local WebSocket boundary tests. The Unity C#
client compiled with a small Unity API shim and passed the same real
ClientWebSocket tests; this does not replace opening and exporting the package
in a licensed Unity editor. The Unreal plugin's protocol core and WebSocket
codec and the template's game rules are plain C++, compiled with g++ and tested
against the same local WebSocket boundary tests and the mock Studio scenarios;
the Unreal wrapper (subsystem, Blueprint types, Slate HUD) was not compiled where
the SDK is built (no Unreal toolchain) and must be built in your Unreal
installation. Always test your target engine version,
platform and packaged game before submitting a release.
