# SDK packages

> The Minekube SDK packages, one per platform - @minekube/paper for Paper, @minekube/velocity for Velocity, @minekube/client for test players, @minekube/runtime under them, and @minekube/network for the Minekube API - 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: one package per platform, named after it, with the platform's own API as a typed service and the glue that mounts a component into it. There is no layer across platforms: what makes rules portable is code that imports no platform, such as `logic` components, Schemas and Commands.

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

## @minekube/paper

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

| Entry point | Export | What |
| --- | --- | --- |
| `@minekube/paper` | `Paper.make(program)` | Defines the game's bundle from an Effect program, run once per revision on the server thread. |
| | `Paper.mount(game, props)` | Mounts a component into the server and records its session. |
| | `Paper.on(event, handler, options?)` | Handles a Paper event while the scope is open, on the server thread inside Paper's dispatch. `options`: `priority`, `ignoreCancelled`. |
| | `Paper.event(eventClass, toMessage, options?)` | A Subscription that turns a Paper event into a component message. `options` adds `cancel` and `key`. |
| | `PaperServer` | The service with `server` (`org.bukkit.Server`), `plugin` and `host`. |
| | `Paper.component`, `Paper.vocabulary`, `Paper.Elements` | Finish a `logic` component for the server. |
| | `Paper.command(name, toMessage, options?)` | A Subscription that makes `/<name>` a server command and turns each run into a message. |
| | `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`). |
| | `Instance.token({ audience })` | A short-lived JWT signed with the server's instance key and issued by its network, for a backend to verify. Fails with `Instance.NoNetwork` on a server in no network, and with `Instance.TokenFailed` for a blank audience, one at the Minekube API itself, or `minekube`. See [Authenticate servers to your backend](https://minekube.com/guide/networks/instance-tokens). |
| `@minekube/paper/prelude` | | Web globals for the bundle: timers on server ticks, `fetch`, `WebSocket`, `URL`, `AbortController`, `TextEncoder`, `console` and more. |
| `@minekube/paper/testing` | `decodeRecording(text)` | Decodes a recording file into its entries, for replay in `bun test`. |

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

## @minekube/velocity

Proxy bundles on Velocity. Import in `proxy/velocity.ts`.

| Entry point | Export | What |
| --- | --- | --- |
| `@minekube/velocity` | `Velocity.make(program)` | Defines the proxy bundle, run once per revision on the proxy. |
| | `Velocity.mount`, `Velocity.component`, `Velocity.vocabulary` | Mount a component into the proxy. |
| | `Velocity.on`, `Velocity.event` | Velocity events as handlers or as component messages. |
| | `Velocity.command(name, toMessage, options?)` | A Subscription that registers the proxy command `/<name>` and turns each run into a message. |
| | `Velocity.register(meta, command)` | Registers any Velocity command while the scope is open. |
| | `Velocity.channel(...)` | Registers a plugin message channel while the scope is open. |
| | `Velocity.future(value)` | A Java `CompletableFuture` as an Effect. |
| | `VelocityServer` | The service with `proxy` (`ProxyServer`), `plugin` and `host`. |
| | `fromJava`, `toJava`, `Jvm`, `Instance` | As in `@minekube/paper`. |
| `@minekube/velocity/prelude`, `/testing` | | As in `@minekube/paper`. |

The Velocity API's types come from `@minekube/velocity-types`, written by the dev proxy.

## @minekube/network

A network as the registry has it, and the Minekube API. The CLI, the Vite plugin and the API use it; a bundle rarely does.

| Entry point | Export | What |
| --- | --- | --- |
| `@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 Minekube API, as Effect Schemas. |
| `@minekube/network/MinekubeApi` | | The Minekube API, an Effect `HttpApi`. |

## @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` | `Client.make(program)` | Defines a client bundle, run once per revision on the client thread. |
| | `Client.mount`, `Client.component`, `Client.vocabulary` | Mount a component into the client. |
| | `MinecraftClient` | The service with `minecraft` (`net.minecraft.client.Minecraft`) and `host`. |
| | `Jvm` | As in `@minekube/paper`. |
| | `Instance` | As in `@minekube/paper`; a client is in no network, so `Instance.token` fails with `NoNetwork`. |
| `@minekube/client/prelude` | | Web globals for the bundle. |

## @minekube/runtime

The shared core under the platform packages. 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 |
| `Instance` | Instance tokens (`Instance.token`), re-exported by each platform package |
| `currentHost` | The platform host of the running bundle |
