1
0
Fork 0
taleweave-ai/docs/events.md

4.6 KiB

TaleWeave AI Events

Contents

Event Types

  • Player events
    • Joining
    • Leaving
  • System events
    • Generating the world?
  • World events
    • Things happening in the world

Player Events

Player events use the following schema:

type: "player"
status: string
character: string
client: string

Player Join Events

Player join events have a status of join:

type: "player"
status: "join"
character: string
client: string

Player Leave Events

Player leave events have a status of leave:

type: "player"
status: "leave"
character: string
client: string

System Events

Generate Events

Generate events are sent every time an entity's name is generated and again when it has been completely generated and added to the world.

type: "generate"
name: string
entity: Room | Character | Item | None

Two generate events will be fired for each entity. The first event will not have an entity set, only the name. The second event after generation is complete will have the same name and the full entity. This helps provide more frequent progress updates when generating with slow models.

World Events

Action Events

The action event is fired after player or character input has been processed and any JSON function calls have been parsed.

type: "action"
action: string
parameters: dict
room: Room
character: Character
item: Item | None

Prompt Events

The prompt event is fired when a character's turn starts and their input is needed for the next action.

type: "prompt"
prompt: string
room: Room
character: Character

Reply Events

The reply event is fired when a character has been asked a question or told a message and replies.

type: "reply"
text: string
room: Room
character: Character

Result Events

The result event is fired after a character has taken an action and contains the results of that action.

type: "result"
result: string
room: Room
character: Character

The result is related to the most recent action for the same character, although not every action will have a result - they may have a reply or error instead.

Status Events

The status event is fired for general events in the world and messages about other characters.

type: "status"
text: string
room: Room | None
character: Character | None

Snapshot Events

The snapshot event is fired at the end of each turn and contains a complete snapshot of the world.

type: "snapshot"
world: Dict
memory: Dict
step: int

This is primarily used to save the world state, but can also be used to sync clients and populate the world menu.

The world and memory fields within the snapshot event have already been serialized to JSON-compatible dictionaries, because they may contain complex classes and implementation details of the underlying LLM.

Server-specific Events

Websocket Server Events

The websocket server has a few unique message types that it uses to communicate metadata with socket clients.

Websocket New Client

Notify a new client of its unique ID.

type: "id"
id: str

This is an outgoing event from the server to clients.

Websocket Player Become Character

A socket client wants to play as a character in the world.

type: "player"
become: str

This is an incoming event from clients to the server.

Websocket Player Input

A socket client has sent some input, usually in response to a prompt.

type: "input"
input: str

This is an incoming event from clients to the server.

Websocket Player Name

Update the player name attached to a socket client.

type: "player"
name: str

This is an incoming event from clients to the server.