Skip to main content
This page documents the public surface of @reactor-models/happy-oyster. For a complete application flow, see the tutorial. Adventure and Directing use worlds and travel. Acting uses characters and performances. The Acting controls section covers its commands, state, and media tracks.

Modes

HappyOyster has three experiences: For Adventure and Directing, select mode: "adventure" or mode: "directing" on the world client or provider before connecting. That mode stays fixed for the client or provider session. Construct a new client, or remount the provider, to switch world modes.

Client construction

These examples configure an Adventure or Directing world session.
In JavaScript, videoElement may be omitted at construction and supplied later with attachVideo(element). React provider props:

Lifecycle

The client lifecycle is available as model.phase or useHappyOyster().phase:

connect

Open the session and synchronize the first worldState snapshot.
With a provider, use autoConnect or call the hook method:

disconnect

End any active travel and close the session. Worlds remain available for later attachment.

endTravelSession

End the active travel while keeping the session and current world.

Worlds

createWorld

Create a world for the client’s selected mode and make it current. The promise resolves with a WorldStateMessage once the world is ready. Shared parameters: Provide only one starting-image source. Either one must be a landscape image with an aspect ratio between 1.5 and 2.0; a taller, narrower, or missing image is rejected before any upload bandwidth is spent. Adventure parameters:
Directing parameters:
Save world.encrypted_world_id to reopen the world later.

attachWorld

Make an existing world current and wait until it is ready:
The world must belong to the client’s selected mode. A world id saved before SDK version 1.0.1 no longer resolves. attachWorld rejects it with code 403001. Drop the saved id and create a new world.

Travel

startTravel

Start the current ready world and render its stream into the attached video element:
The method is single-flight: concurrent calls share one attempt. Calling it while already streaming returns the current result. StartTravelResult:

Session length

An Adventure travel runs for up to 2 minutes, and the stream ends when that budget runs out. A Directing travel runs for up to 3 minutes. maxExperienceTimeSec reports the length granted to the live Adventure travel, typed number | null. It reads null while no travel is open, and for every Directing travel:
React:
Size a clock from the granted length, with ADVENTURE_MAX_EXPERIENCE_SEC covering the render before a travel is open:
endTravelSession() ends a travel before its length runs out.

Video in React

Mount HappyOysterVideo under the provider before starting:

Adventure controls

Adventure controls are held state. Movement, look, and interaction axes compose until released.

move

Values: Front, Back, Left, Right, the four diagonal combinations, and None.

look

Values: Mouse_Up, Mouse_Down, Mouse_Left, Mouse_Right, the four diagonal combinations, and None.

interact

Built-in verbs include Jump, Attack, Crouch, and Sprint. The current world’s advertised verbs are available in travelState.character_actions and travelState.environment_actions.

hold

Set multiple axes in one call:

release

Release selected axes while leaving the others held:

stop

Release every axis:

Directing controls

instruct

Submit a text instruction:
Accepted instructions appear in travelState.user_instructions.

pause

resume

rewind

Rewind a paused travel to an absolute second. Playback resumes automatically:
Targets use 4-second boundaries; other values are rounded down.

Travel status

React:

State

worldState

The authoritative current-world snapshot: Subscribe from the class:
Or read the reactive value from useHappyOyster().

travelState

The authoritative live-travel snapshot:

React hook surface

useHappyOyster() returns:
  • model, mode, phase, worldState, travelState, and streaming
  • maxExperienceTimeSec, the granted travel length in seconds, or null when no Adventure travel is open
  • connect, disconnect, createWorld, attachWorld, startTravel, and endTravelSession
  • Adventure methods: move, look, interact, hold, release, stop, and control
  • Directing methods: instruct, pause, resume, and rewind
Additional hooks:
  • useHappyOysterWorldState()
  • useHappyOysterTravelState()
  • useHappyOysterPhase()
  • useHappyOysterTravelStatus(handler)
  • useHappyOysterTravelError(handler)

Errors

HappyOysterActionError exposes the rejected action and a machine-readable code.

Acting controls

Acting creates reusable characters and streams their performances through reactor/happy-oyster-acting. Save a character for later performances, just as you save a world for later travels. Character ids and world ids identify different resources.

Character and performance lifecycle

A build or performance can fail. Mirror session_state, including when a client joins or reconnects. Clear the old snapshot when the connection ends. Character ids differ from world ids. Save the account-scoped character_id to reuse the character in a later session with attach_character. Reuse a character only within its owning account. The API does not specify a retention period. Handle CHARACTER_NOT_FOUND if a saved id can no longer be attached. Creating or attaching a character does not start a performance. Enable start_performance only in ready, ended, or failed when character_status is ready. Show progress from the snapshot. Build and startup times in the schema are estimates.

Replies, state, and errors

get_state and end_performance return correlated replies to the caller. Read these replies from the awaited command call. Mirror session_state broadcasts to track later changes, including character build progress and performance transitions. Other Acting commands declare no reply payload. A command acknowledgment does not establish that a character is ready or that media is playing. A successful end_performance reply also does not enable another start. Wait for snapshot phase ended after cleanup. The character stays attached. Handle SDK call and transport failures alongside the model errors declared by the schema. The snapshot retains the latest model error in last_error, including failures after acknowledgment. The model also broadcasts command_error messages. An absent reply payload alone does not establish success or failure. The SDK error guide covers call failures. Use code for error handling and reason for display. A failure with command: "session" has no triggering client command. Offer a retry according to retryable, phase, and character readiness. A rejected instruction can leave the performance live.

Playback and timers

Display character video from main_video with speech from main_audio. Preserve the frame’s aspect ratio. The schema declares no incoming microphone track. Supply a playback control for browsers that block audible autoplay, and set muting for the intended sound behavior. Received-media flags do not establish audible playback. Paused instructions take effect after resume. Paused time does not consume the active performance limit, but performance_elapsed_seconds includes it. Do not subtract elapsed seconds from performance_max_seconds to compute active time remaining after a pause. Treat missing or null instruction lists as empty. A pending instruction becomes performed in the authoritative snapshot; acknowledgment alone does not mean the character performed it. The following reference comes from the pinned schema. Command fields, defaults, and reply payloads follow that schema. Model: reactor/happy-oyster-acting. Schema version: v0.1.0.

Acting Tracks

Acting Commands

Acting pause

Pause the performance. Valid while live. Returns nothing once the generation service has paused; session_state moves to paused, the picture holds its last frame, and the voice goes quiet. instruct still works while paused. Emits command_error with NOT_LIVE unless live. Parameters No fields declared. Reply payload: no JSON body declared.

Acting resume

Resume a paused performance. Valid while paused. Returns nothing once the generation service has resumed; session_state moves to live and video returns about 2 s later (video_receiving). Emits command_error with NOT_PAUSED unless paused. Parameters No fields declared. Reply payload: no JSON body declared.

Acting instruct

Tell the character what to do or say next, in plain language: “She laughs and asks how my day was.” Valid while live or paused; a paused performance acts on it after resume. Returns nothing once the instruction is accepted; it appears in session_state.instructions as pending, and turns performed a few seconds later. Emits command_error with NOT_LIVE outside a performance, INVALID_INPUT when the text is empty or over 2,000 characters, and CONTENT_POLICY when the generation service refuses it; the performance keeps running. Parameters Reply payload: no JSON body declared.

Acting get_state

Return the authoritative snapshot. Valid any time. Replies session_state; never fails. Parameters No fields declared. Reply payload: SessionState.

Acting end_performance

End the performance. Valid in starting, live, and paused. Replies performance_ended once the performance has stopped, about 2 s later; session_state moves to ending, then to ended about 10 s later when everything is released, and start_performance works again. The character stays. Emits command_error with NOT_LIVE when no performance is in progress. Parameters No fields declared. Reply payload: PerformanceEnded.

Acting attach_character

Make a character created in an earlier session this session’s character, by its character_id. Valid any time no performance is in progress. Returns nothing; session_state moves to ready, or to building when the character is still being built. Emits command_error with BUSY during a performance, INVALID_INPUT with no id, and CHARACTER_NOT_FOUND when the id is unknown or belongs to another model. Parameters Reply payload: no JSON body declared.

Acting create_character

Create a character from a prompt and a first-frame image, and make it this session’s character. Valid any time no performance is in progress. Returns nothing; session_state moves to building with the new character_id (save it), then to ready after about 2 min at 480p or 4 min at 720p. Emits command_error with BUSY during a performance, and INVALID_INPUT when the prompt is empty or over 2,000 characters, the image is missing, given twice, unreadable, or the wrong shape for aspect_ratio. CONTENT_POLICY when the prompt or image is refused; CHARACTER_FAILED (phase failed) when the build fails. Parameters Reply payload: no JSON body declared.

Acting start_performance

Start a performance of this session’s character. Valid in ready, ended, and failed once character_status is ready. Returns nothing; session_state moves to starting, then to live when the first frame arrives on main_video, about 10 s later. A performance ends on its own after about 3 min (end_reason max_duration). Emits command_error with BUSY during a performance, NO_CHARACTER with no character, and CHARACTER_NOT_READY while it builds. A failure while starting moves the phase to failed: UPSTREAM_CAPACITY when the generation service has no free performer (retry shortly), NO_STREAM, MEDIA_JOIN_FAILED, or another UPSTREAM_* code. Parameters No fields declared. Reply payload: no JSON body declared.

Acting Messages

Acting command_error

Emitted when a command is rejected or a performance fails; the command had no effect. Broadcast, and stored as session_state.last_error. origin says whose fault it is; code is stable and safe to branch on. Payload CommandError

Acting session_state

Emitted on connect, on every change, and as the reply to get_state: the snapshot. The authoritative state of the session, broadcast to every client. Mirror it; derive nothing from other messages. Payload SessionState

Acting performance_ended

Emitted as the reply to end_performance once the performance is released. Payload PerformanceEnded

Acting Shared types

Acting Type: CommandError

Acting Type: SessionState

Acting Type: PerformanceEnded

Acting Type: ReactorUploadReference

Reference to a file uploaded via the Reactor upload protocol.