Skip to content

Latest commit

 

History

History
54 lines (38 loc) · 2.05 KB

File metadata and controls

54 lines (38 loc) · 2.05 KB

@hotrepl/protocol

npm license

TypeScript types and JSON schemas for the HotRepl WebSocket protocol — the wire format a HotRepl-instrumented Unity game speaks to its clients (SDK, CLI, MCP server, custom integrations).

Most consumers should depend on @hotrepl/sdk instead. Use this package directly only when you are building an alternative SDK, a non-TypeScript client, or a tool that needs the schemas (e.g., a code generator or a test fixture validator).

Install

bun add @hotrepl/protocol      # or: npm install @hotrepl/protocol

What's in the box

  • TypeScript types for every protocol message (HandshakeMessage, EvalResultMessage, CommandCallMessage, JobAcceptedMessage, SessionEvictedMessage, …).
  • Discriminant constantsMESSAGE_TYPES, PROTOCOL_VERSION, ERROR_KINDS, defaultLimits.
  • JSON Schema files for every public message, exported under schemas/ and generated from the same TypeScript source via bun run schemas:export.

Usage

import { type HandshakeMessage, MESSAGE_TYPES, PROTOCOL_VERSION } from "@hotrepl/protocol";

function isHandshake(message: { type: string }): message is HandshakeMessage {
  return message.type === MESSAGE_TYPES.handshake;
}

Schemas (Draft 2020-12) live alongside the types if you need to validate wire frames:

import handshakeSchema from "@hotrepl/protocol/schemas/handshake.schema.json"
  with { type: "json" };

Reference

License

MIT