Unique identifier for this world instance.
Unique identifier for this world instance (alias for id).
Add a new entity to the world.
Entity name, type, optional profile and initial space.
The mutate operation result with optional data.
Add a new space to the world.
Space name, optional type and capacity.
The mutate operation result with optional data.
Send a message to an entity and get an emotion-processed response.
With LLM adapter: Fetches world context, generates a response via the configured LLM, then sends it to the API for emotion processing.
Without LLM adapter: Requires options.appraisal to be provided.
Sends the message directly to the API.
Target entity name (e.g., 'Sera').
The message text to send.
Optionaloptions: ChatOptionsChat options (from, appraisal, history, propagateToSpace).
Chat result with emotion data and optional observer reactions.
// With LLM (automatic appraisal)
const result = await world.chat('Sera', 'How are you?');
console.log(result.response.emotion.discrete.primary); // 'joy'
// Without LLM (manual appraisal)
const result2 = await world.chat('Sera', 'Hello', {
appraisal: { goal_relevance: 0.5, goal_congruence: 0.8, ... },
});
Soft-delete this world. Can be restored with restore.
Dispatch a world event that affects one or more entities.
Events can target specific entities or broadcast to a space. Optional stimulus parameters allow direct manipulation of emotion state.
Event type, target, payload, and optional appraisal/stimulus.
Affected entities with their emotion responses.
Fetch persona configs from API and cache locally.
Get the world context from the perspective of a specific entity.
Returns spatial awareness, nearby entities, recent events, and world state.
Entity name or ID to get context for.
World context data used for LLM prompt building.
Get cached persona config for a specific entity.
Restore the world state from a previously saved snapshot.
The snapshot to restore.
Load a world snapshot from external storage and apply it. Requires a StorageAdapter to be configured.
Optionalkey: stringStorage key. Defaults to snapshots/{worldId}/latest.json.
Move an entity to a different space.
Entity name or ID to move.
Destination space name or ID.
Execute one or more mutation operations on the world atomically.
Supports: add/remove entities, move entities, set relationships, add spaces/connections, update environment, manage facts/phases.
Array of mutation operations.
Results for each operation (ok/error).
Query world state, selecting which data to include.
Optionalinclude: QueryInclude[]Data sections to include (entities, spaces, environment, definition, phase). If omitted, returns all sections.
Selected world state data.
Remove an entity from the world.
Entity name or ID to remove.
Restore a previously soft-deleted world.
Save current world snapshot to external storage. Requires a StorageAdapter to be configured.
Optionalkey: stringStorage key. Defaults to snapshots/{worldId}/latest.json.
The snapshot that was saved.
Set a relationship between two entities.
First entity name.
Second entity name.
Relationship data (type, strength, trust).
Get a full snapshot of the world state, including all entities, spaces, environment, knowledge, progression, and persona snapshots.
Complete world snapshot that can be saved and restored.
Advance world time by the specified number of seconds.
Processes emotion decay, pending events, and phase transitions.
Number of seconds to advance.
Tick result with elapsed time and any phase changes.
Jump forward in time with an optional milestone event.
Unlike tick, time jumps can span large periods and optionally inject a milestone event at the destination time.
Number of seconds to jump forward.
OptionalmilestoneEvent: Record<string, unknown>Optional event to inject at the destination time.
Tick result with elapsed time and any phase changes.
Update the world definition (identity, rules, culture, etc.).
Partial definition to merge with the existing one.
Update the world environment (weather, location, ambiance, etc.).
Partial environment data to merge.
StaticconnectConnect to an existing world by ID.
Verifies the world exists and fetches persona configs.
API connection config and optional adapters.
The ID of the world to connect to.
A connected MolrooWorld instance.
StaticcreateCreate a new world on the molroo API and return a connected instance.
API connection config and optional adapters.
World definition, entities, spaces, and persona configs.
A connected MolrooWorld instance.
StaticlistList all worlds for the authenticated tenant.
API connection config (baseUrl + apiKey).
List of world summaries with optional pagination cursor.
Main SDK entry point for interacting with a molroo world instance.
Provides methods for chat, events, ticking, time jumps, mutations, snapshots, and querying world state. Optionally integrates with LLM, storage, memory, and event adapters for richer functionality.
Example