Core: sessions and universes¶
axiom.session¶
axiom/session.py
High-level public API of the Axiom engine (headless, zero Qt).
A Session composes the engine building blocks (Arbitrator, EventSourcer, CheckpointManager, VectorMemory) and exposes a synchronous game loop that any application (GUI, CLI, server) can drive:
from axiom.session import Session
from axiom.config import load_config, build_llm_from_config
llm = build_llm_from_config(load_config())
sess = Session("universes/my_world.axiom", save_id, llm=llm)
result = sess.take_turn("I open the door.", on_token=print)
Streaming happens through the on_token callback. The method is synchronous: on the GUI side, the app wraps it in a QThread (see workers/narrative_worker.py).
- axiom.session.IMAGE_GEN_STATUS = 'Generating scene illustration...'¶
Status string emitted right before contextual image generation starts. Exposed as a constant so the GUI can react (e.g. show a placeholder) without matching a hard-coded English message.
- class axiom.session.Session(universe_path, save_id, *, llm, vector_memory=None, data_dir=None, mode='Normal', hero_llm=None, time_llm=None)[source]¶
High-level wrapper to play one save of a universe.
- Parameters:
universe_path (str | Path) – Path of the universe file (.axiom / SQLite .db).
save_id (str) – Identifier of the active save.
llm (LLMBackend) – Pre-built LLM backend (see build_llm_from_config).
vector_memory (VectorMemory | None) – Vector memory. If None, a VectorMemory is created under <data_dir>/vector/<save_id> (or the app’s default vector folder when data_dir is None).
data_dir (str | Path | None) – Optional data root for path injection (only used for the default VectorMemory).
mode (str) – Game mode (‘Normal’, ‘Hardcore’, ‘Companion’).
hero_llm (LLMBackend | None) – Optional backend for the hero’s decision (Companion mode). If None, lazily built from the config (local extraction_model), like the worker does.
time_llm (LLMBackend | None)
- submit_intent(entity_id, intent_text)[source]¶
Submit an action intent to the pool for the current turn.
- resolve_tick(*, on_token=None, on_status=None, temperature=0.7, top_p=1.0, verbosity_level='balanced', hero_entity_id=None)[source]¶
Resolve every intent currently in the pool as a single tick.
- take_turn(player_input, *, player_id='player', on_token=None, on_status=None, on_hero_decision=None, temperature=0.7, top_p=1.0, verbosity_level='balanced', hero_action=None, hero_entity_id=None)[source]¶
Run a full turn (synchronously) and return the result.
Wraps submit_intent and resolve_tick for backward compatibility.
- Parameters:
- Return type:
- rewind(target_turn_id)[source]¶
Bring the save back to its state at turn target_turn_id.
Invalidates the Arbitrator’s stats cache and resynchronises turn_id. Returns the summary provided by CheckpointManager.rewind.
- regenerate_variant(turn_id, history, user_message, temperature=0.7, top_p=1.0, verbosity_level='balanced', player_id='player_1', on_token=None)[source]¶
Regenerate a variant of turn turn_id’s narrative text.
Replays the same player message to produce an alternative text (without re-evaluating rules or stats); the variant is appended to the turn’s multiverse payload and becomes active. Delegates to axiom.regenerate.
axiom.universe¶
axiom/universe.py
Headless representation of an Axiom universe (a .axiom file = SQLite database).
Exposes the metadata (name, system prompt) and the list of saves, with no Qt dependency whatsoever. Entry point: Universe.load(path).
- class axiom.universe.Universe(path, name, system_prompt)[source]¶
A loaded universe (read-only view of its metadata).
- path¶
Path of the universe file (.axiom / SQLite .db).
- name¶
Display name of the universe.
- system_prompt¶
Founding system prompt handed to the narrator.