# SDK packages

> The Minekube SDK packages - @minekube/games for Paper, @minekube/network for Velocity, @minekube/client for test players, and @minekube/runtime under them - with every entry point and what it exports.

The SDKs are TypeScript packages on [Effect](https://effect.website) 4. Components, Commands and Stories come from Effect itself, `effect/ui` and `effect/ui/testing`. The Minekube packages add the platform: the server's API as typed services, and the glue that mounts a component into the server.

The release ships `@minekube/runtime`, `@minekube/games` and `@minekube/network` as packages. `@minekube/client` is in the repository and not in the release yet.

## @minekube/games

Games on Paper. Import in `src/game.ts` and the files it uses.

| Entry point | Export | What |
| --- | --- | --- |
| `@minekube/games` | `Game.make(program)` | Defines the game's bundle from an Effect program, run once per revision on the server thread. |
| | `Game.mount(game, props)` | Mounts a component into the server and records its session. |
| | `Game.on(event, handler, options?)` | Handles a Paper event while the scope is open, on the server thread inside Paper's dispatch. `options`: `priority`, `ignoreCancelled`. |
| | `Game.event(eventClass, toMessage, options?)` | A Subscription that turns a Paper event into a component message. `options` adds `cancel` and `key`. |
| | `Paper` | The service with `server` (`org.bukkit.Server`), `plugin` and `host`. |
| | `Minecraft.component`, `Minecraft.vocabulary`, `Minecraft.Elements` | The component definition for Minecraft elements. |
| | `Recording.kept`, `Recording.hello` | How many recordings are kept, and the header of a server recording. |
| | `fromJava`, `toJava` | Convert between Java values and their data form in messages. |
| | `Jvm` | Java calls with checked exceptions as typed failures (`Jvm.attempt`), and Java resources closed with the scope (`Jvm.acquire`). |
| `@minekube/games/prelude` | | Web globals for the bundle: timers on server ticks, `fetch`, `WebSocket`, `URL`, `AbortController`, `TextEncoder`, `console` and more. |
| `@minekube/games/testing` | `decodeRecording(text)` | Decodes a recording file into its entries, for replay in `bun test`. |

The Paper API's types come from `@minekube/paper`, which the CLI generates. Its `schemas` entry point holds the Schemas for Java values in messages.

## @minekube/network

Network bundles on Velocity. Import in `network/velocity.ts`.

| Entry point | Export | What |
| --- | --- | --- |
| `@minekube/network` | `Network.make(program)` | Defines the network bundle, run once per revision on the proxy. |
| | `Network.mount`, `Network.component`, `Network.vocabulary` | Mount a component into the proxy. |
| | `Network.on`, `Network.event` | Velocity events as handlers or as component messages. |
| | `Network.command(name, toMessage, options?)` | A Subscription that registers the proxy command `/<name>` and turns each run into a message. |
| | `Network.register(meta, command)` | Registers any Velocity command while the scope is open. |
| | `Network.channel(...)` | Registers a plugin message channel while the scope is open. |
| | `Network.future(value)` | A Java `CompletableFuture` as an Effect. |
| | `Velocity` | The service with `proxy` (`ProxyServer`), `plugin` and `host`. |
| | `fromJava`, `toJava`, `Jvm` | As in `@minekube/games`. |
| `@minekube/network/LabelSelector` | `parse`, `format`, `matches`, `FromString`, `Labels`, `LabelSelector`, `InvalidSelector` | Label selectors as in Kubernetes. See [Labels and selectors](https://minekube.com/guide/networks/labels). |
| `@minekube/network/Registry` | | The messages between connectors, relays and the registry, as Effect Schemas. |
| `@minekube/network/RegistryApi` | | The registry's HTTP API, an Effect `HttpApi`. |
| `@minekube/network/prelude`, `/testing` | | As in `@minekube/games`. |

## @minekube/client

Bundles for test players in the Minecraft client. See [Test with bot clients](https://minekube.com/games/testing/bots).

| Entry point | Export | What |
| --- | --- | --- |
| `@minekube/client` | `make(program)` | Defines a client bundle, run once per revision on the client thread. |
| | `mount`, `component`, `vocabulary` | Mount a component into the client. |
| | `Client` | The service with `minecraft` (`net.minecraft.client.Minecraft`) and `host`. |
| | `Jvm` | As in `@minekube/games`. |
| `@minekube/client/prelude` | | Web globals for the bundle. |

## @minekube/runtime

The shared core under the other three. You rarely import it directly.

| Export | What |
| --- | --- |
| `Bundle` | Runs an Effect program as a bundle, once per revision, until it ends or the revision stops |
| `Mount` | Mounting a component into a host, with its recording |
| `Recording` | The recording format and how many are kept |
| `Supervisor` | Restarts a failed game, and stops it after too many failures |
| `Tree` | The tree a bundle's view renders into, in the shape `effect/ui/testing` locators read |
| `Jvm`, `Values` | Java calls and value conversion |
| `currentHost` | The platform host of the running bundle |
