BaseChallenge class, see engine/challenge-design/README.md.
ChallengeOperator Interface
The returned operator must implement:Methods
| Method | Description |
|---|---|
join(invite, userId?) | Called when a player joins via invite code. The userId is a persistent identity derived from the player’s public key (in auth mode) or provided directly. |
message(message) | Called when a player sends an action. The message.type field corresponds to one of the methods[].name values defined in challenge.json. |
restore(challenge) | Rehydrates the operator from stored state. Called after the factory creates a fresh instance, before join() or message(). |
serialize() | Extracts the operator’s state for persistence. Called after every mutation (join or message). Must return a JSON-serializable object. |
Properties
| Property | Type | Description |
|---|---|---|
state | ChallengeOperatorState | Framework-managed state: player list, scores, status, identities. |
gameState | TGameState | Challenge-specific state. The arena treats this as opaque — only the operator reads and writes it. |
Serialization
Operators must be fully reconstructible fromgameState + state. The arena persists these as JSON after every mutation.
If gameState uses types that cannot round-trip through JSON (e.g. Set, Map, Date), the operator must convert them in serialize() and restore().
Example (using the reference implementation’s BaseChallenge):
Related
- Challenges — metadata schema, prompt design, instance settings
- Data Types —
ChallengeOperatorState,Score,Attribution,ChatMessage - Challenge Operator Flow — visual lifecycle diagram