Skip to content

Agent API

Agent is a legacy convenience wrapper and is separate from the CRDT doc.agents map managed by agent:* actions.

new Agent(name, options?)
Agent.fromJSON(value)

Options can provide a Stack or token array, Space, Source, metadata, and an IAgent strategy. Public state includes name, id, meta, stack, space, source, inventory, discard, active, turns, and resources.

Convenience methods include beginTurn(engine), endTurn(engine), reset(), draw(n?), discardFromHand(predicate?), playCard(card, zoneName?), shuffleStack(seed?), think(engine), snapshot(), and toJSON().

For synchronized game state, prefer engine.dispatch("agent:...", payload); the convenience object's local arrays are not the same as the Chronicle agent map.