realm-fabric 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- realm_fabric-0.7.0/.gitignore +158 -0
- realm_fabric-0.7.0/LICENSE +21 -0
- realm_fabric-0.7.0/PKG-INFO +154 -0
- realm_fabric-0.7.0/README.md +124 -0
- realm_fabric-0.7.0/profiles/default_compound/few_shots.txt +63 -0
- realm_fabric-0.7.0/profiles/default_compound/template.txt +17 -0
- realm_fabric-0.7.0/pyproject.toml +75 -0
- realm_fabric-0.7.0/realm_fabric/__init__.py +131 -0
- realm_fabric-0.7.0/src/__init__.py +15 -0
- realm_fabric-0.7.0/src/action_outcome.py +18 -0
- realm_fabric-0.7.0/src/actions/__init__.py +14 -0
- realm_fabric-0.7.0/src/actions/emote.py +24 -0
- realm_fabric-0.7.0/src/actions/interact.py +624 -0
- realm_fabric-0.7.0/src/actions/move.py +349 -0
- realm_fabric-0.7.0/src/actions/speak.py +18 -0
- realm_fabric-0.7.0/src/agent.py +96 -0
- realm_fabric-0.7.0/src/area.py +382 -0
- realm_fabric-0.7.0/src/area_edit.py +1216 -0
- realm_fabric-0.7.0/src/area_event.py +29 -0
- realm_fabric-0.7.0/src/compound_stepper.py +110 -0
- realm_fabric-0.7.0/src/coordinates.py +53 -0
- realm_fabric-0.7.0/src/emote_phrasing.py +40 -0
- realm_fabric-0.7.0/src/game_profile.py +173 -0
- realm_fabric-0.7.0/src/grid.py +8 -0
- realm_fabric-0.7.0/src/interact_templates.py +71 -0
- realm_fabric-0.7.0/src/interaction_handlers/__init__.py +23 -0
- realm_fabric-0.7.0/src/interaction_handlers/base.py +27 -0
- realm_fabric-0.7.0/src/interaction_handlers/registry.py +111 -0
- realm_fabric-0.7.0/src/llm/__init__.py +3 -0
- realm_fabric-0.7.0/src/llm/client.py +142 -0
- realm_fabric-0.7.0/src/llm/memory_summary.py +87 -0
- realm_fabric-0.7.0/src/llm/prompt.py +43 -0
- realm_fabric-0.7.0/src/llm/prompt_context.py +257 -0
- realm_fabric-0.7.0/src/llm/schemas.py +148 -0
- realm_fabric-0.7.0/src/llm/text_truncation.py +111 -0
- realm_fabric-0.7.0/src/llm/token_estimate.py +15 -0
- realm_fabric-0.7.0/src/llm/types.py +20 -0
- realm_fabric-0.7.0/src/log_utils/__init__.py +13 -0
- realm_fabric-0.7.0/src/log_utils/logger.py +153 -0
- realm_fabric-0.7.0/src/lorebook/__init__.py +28 -0
- realm_fabric-0.7.0/src/lorebook/factory.py +37 -0
- realm_fabric-0.7.0/src/lorebook/import_st.py +70 -0
- realm_fabric-0.7.0/src/lorebook/listing.py +17 -0
- realm_fabric-0.7.0/src/lorebook/matcher.py +111 -0
- realm_fabric-0.7.0/src/lorebook/models.py +123 -0
- realm_fabric-0.7.0/src/lorebook/scan_config.py +90 -0
- realm_fabric-0.7.0/src/lorebook/st_defaults.py +99 -0
- realm_fabric-0.7.0/src/main.py +624 -0
- realm_fabric-0.7.0/src/memory.py +154 -0
- realm_fabric-0.7.0/src/memory_modules/__init__.py +27 -0
- realm_fabric-0.7.0/src/memory_modules/base.py +85 -0
- realm_fabric-0.7.0/src/memory_modules/consolidation_runner.py +179 -0
- realm_fabric-0.7.0/src/memory_modules/formatting/__init__.py +33 -0
- realm_fabric-0.7.0/src/memory_modules/formatting/common.py +93 -0
- realm_fabric-0.7.0/src/memory_modules/formatting/salient.py +34 -0
- realm_fabric-0.7.0/src/memory_modules/formatting/summary.py +32 -0
- realm_fabric-0.7.0/src/memory_modules/loader.py +106 -0
- realm_fabric-0.7.0/src/memory_modules/recent_turns.py +100 -0
- realm_fabric-0.7.0/src/memory_modules/registry.py +261 -0
- realm_fabric-0.7.0/src/memory_modules/rolling_summary.py +297 -0
- realm_fabric-0.7.0/src/memory_modules/salient_turns.py +286 -0
- realm_fabric-0.7.0/src/memory_modules/serialization.py +101 -0
- realm_fabric-0.7.0/src/move_target.py +288 -0
- realm_fabric-0.7.0/src/object.py +133 -0
- realm_fabric-0.7.0/src/object_action.py +41 -0
- realm_fabric-0.7.0/src/observations.py +118 -0
- realm_fabric-0.7.0/src/occupancy.py +244 -0
- realm_fabric-0.7.0/src/pathfinding.py +93 -0
- realm_fabric-0.7.0/src/pathing.py +57 -0
- realm_fabric-0.7.0/src/perception.py +430 -0
- realm_fabric-0.7.0/src/prompt_blocks.py +462 -0
- realm_fabric-0.7.0/src/prompt_template.py +57 -0
- realm_fabric-0.7.0/src/session.py +1188 -0
- realm_fabric-0.7.0/src/session_area_edit.py +297 -0
- realm_fabric-0.7.0/src/session_persistence.py +351 -0
- realm_fabric-0.7.0/src/simulation.py +288 -0
- realm_fabric-0.7.0/src/snapshot.py +213 -0
- realm_fabric-0.7.0/src/stepper_commands.py +72 -0
- realm_fabric-0.7.0/src/triggers.py +119 -0
- realm_fabric-0.7.0/src/turn_record.py +31 -0
- realm_fabric-0.7.0/src/utils/__init__.py +5 -0
- realm_fabric-0.7.0/src/vision_bearing.py +94 -0
- realm_fabric-0.7.0/src/world_edit_api.py +460 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
*.manifest
|
|
29
|
+
*.spec
|
|
30
|
+
|
|
31
|
+
# Installer logs
|
|
32
|
+
pip-log.txt
|
|
33
|
+
pip-delete-this-directory.txt
|
|
34
|
+
|
|
35
|
+
# Unit test / coverage reports
|
|
36
|
+
htmlcov/
|
|
37
|
+
.tox/
|
|
38
|
+
.nox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
*.cover
|
|
45
|
+
*.py,cover
|
|
46
|
+
.hypothesis/
|
|
47
|
+
.pytest_cache/
|
|
48
|
+
|
|
49
|
+
# Translations
|
|
50
|
+
*.mo
|
|
51
|
+
*.pot
|
|
52
|
+
|
|
53
|
+
# Django stuff
|
|
54
|
+
*.log
|
|
55
|
+
local_settings.py
|
|
56
|
+
db.sqlite3
|
|
57
|
+
db.sqlite3-journal
|
|
58
|
+
|
|
59
|
+
# Flask stuff
|
|
60
|
+
instance/
|
|
61
|
+
.webassets-cache
|
|
62
|
+
|
|
63
|
+
# Scrapy stuff
|
|
64
|
+
.scrapy
|
|
65
|
+
|
|
66
|
+
# Sphinx documentation
|
|
67
|
+
docs/_build/
|
|
68
|
+
|
|
69
|
+
# PyBuilder
|
|
70
|
+
.pybuilder/
|
|
71
|
+
target/
|
|
72
|
+
|
|
73
|
+
# Jupyter Notebook
|
|
74
|
+
.ipynb_checkpoints
|
|
75
|
+
|
|
76
|
+
# IPython
|
|
77
|
+
profile_default/
|
|
78
|
+
ipython_config.py
|
|
79
|
+
|
|
80
|
+
# pyenv
|
|
81
|
+
.python-version
|
|
82
|
+
|
|
83
|
+
# pipenv
|
|
84
|
+
Pipfile.lock
|
|
85
|
+
|
|
86
|
+
# poetry
|
|
87
|
+
poetry.lock
|
|
88
|
+
|
|
89
|
+
# pdm
|
|
90
|
+
.pdm.toml
|
|
91
|
+
.pdm-python
|
|
92
|
+
.pdm-build/
|
|
93
|
+
|
|
94
|
+
# PEP 582
|
|
95
|
+
__pypackages__/
|
|
96
|
+
|
|
97
|
+
# Celery stuff
|
|
98
|
+
celerybeat-schedule
|
|
99
|
+
celerybeat.pid
|
|
100
|
+
|
|
101
|
+
# SageMath parsed files
|
|
102
|
+
*.sage.py
|
|
103
|
+
|
|
104
|
+
# Environments
|
|
105
|
+
.env
|
|
106
|
+
.env.local
|
|
107
|
+
.venv
|
|
108
|
+
env/
|
|
109
|
+
venv/
|
|
110
|
+
ENV/
|
|
111
|
+
env.bak/
|
|
112
|
+
venv.bak/
|
|
113
|
+
|
|
114
|
+
# Spyder project settings
|
|
115
|
+
.spyderproject
|
|
116
|
+
.spyproject
|
|
117
|
+
|
|
118
|
+
# Rope project settings
|
|
119
|
+
.ropeproject
|
|
120
|
+
|
|
121
|
+
# mkdocs documentation
|
|
122
|
+
/site
|
|
123
|
+
|
|
124
|
+
# mypy
|
|
125
|
+
.mypy_cache/
|
|
126
|
+
.dmypy.json
|
|
127
|
+
dmypy.json
|
|
128
|
+
|
|
129
|
+
# Pyre type checker
|
|
130
|
+
.pyre/
|
|
131
|
+
|
|
132
|
+
# pytype static type analyzer
|
|
133
|
+
.pytype/
|
|
134
|
+
|
|
135
|
+
# Cython debug symbols
|
|
136
|
+
cython_debug/
|
|
137
|
+
|
|
138
|
+
# IDEs
|
|
139
|
+
.idea/
|
|
140
|
+
.vscode/
|
|
141
|
+
*.swp
|
|
142
|
+
*.swo
|
|
143
|
+
*~
|
|
144
|
+
|
|
145
|
+
# OS generated files
|
|
146
|
+
.DS_Store
|
|
147
|
+
.DS_Store?
|
|
148
|
+
._*
|
|
149
|
+
.Spotlight-V100
|
|
150
|
+
.Trashes
|
|
151
|
+
ehthumbs.db
|
|
152
|
+
Thumbs.db
|
|
153
|
+
|
|
154
|
+
# Project specific
|
|
155
|
+
logs/
|
|
156
|
+
*.log
|
|
157
|
+
examples/web/realm-studio/frontend/tokens/pip.png
|
|
158
|
+
examples/web/realm-studio/.custom_modules/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DaveH-Ghost
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: realm-fabric
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Grid-based LLM agent simulation engine — Session API, multi-area worlds, tactical movement, compound turns, pluggable memory
|
|
5
|
+
Project-URL: Homepage, https://github.com/DaveH-Ghost/Realm-Fabric
|
|
6
|
+
Project-URL: Documentation, https://github.com/DaveH-Ghost/Realm-Fabric/blob/main/docs/README.md
|
|
7
|
+
Project-URL: Repository, https://github.com/DaveH-Ghost/Realm-Fabric
|
|
8
|
+
Project-URL: Issues, https://github.com/DaveH-Ghost/Realm-Fabric/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/DaveH-Ghost/Realm-Fabric/blob/main/docs/changelog/README.md
|
|
10
|
+
Author-email: DaveH-Ghost <davidhall.a27@gmail.com>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: agents,game-engine,grid,llm,roleplay,simulation
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Games/Entertainment
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Requires-Dist: openai
|
|
26
|
+
Requires-Dist: pydantic
|
|
27
|
+
Requires-Dist: python-dotenv
|
|
28
|
+
Requires-Dist: rich
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# Realm Fabric
|
|
32
|
+
|
|
33
|
+
Grid-based LLM agent simulation engine: multi-area worlds, compound turns (move → look → speak → interact/emote), pluggable memory modules, and a stable `realm_fabric` library API. The `realm` CLI and [realm-studio](examples/web/realm-studio) are reference clients — apps build on the engine with their own UI and scenarios.
|
|
34
|
+
|
|
35
|
+
**License:** [MIT](LICENSE) — open source.
|
|
36
|
+
|
|
37
|
+
**Current version:** **V0.7.0** (`0.7.0` in `pyproject.toml`) — stable `realm_fabric` exports, typed `Session` world API, [documentation](docs/README.md), and [minimal-server](examples/minimal-server/). **0.7.1** on this repo is for engine follow-ups from the external demo; the demo itself will version from **0.1.0** in its own repository.
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
```powershell
|
|
42
|
+
# Engine + CLI
|
|
43
|
+
cd path\to\Realm-Fabric
|
|
44
|
+
uv sync
|
|
45
|
+
uv run realm
|
|
46
|
+
|
|
47
|
+
# Example web UI
|
|
48
|
+
cd examples\web\realm-studio
|
|
49
|
+
uv sync
|
|
50
|
+
copy ..\..\..\.env.example .env # optional; or use Settings gear in the UI
|
|
51
|
+
uv run realm-studio
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
On Windows, if Smart App Control blocks `uv run realm-studio`, use:
|
|
55
|
+
|
|
56
|
+
```powershell
|
|
57
|
+
uv run python -m backend.main
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Open [http://127.0.0.1:8765](http://127.0.0.1:8765). See [realm-studio README](examples/web/realm-studio/README.md).
|
|
61
|
+
|
|
62
|
+
## Library API
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from realm_fabric import Session, load_profile, AgentCompoundTurn
|
|
66
|
+
|
|
67
|
+
session = Session.from_profile(load_profile("default_compound"))
|
|
68
|
+
session.create_agent(name="Scout", position=(0, 0), personality="...")
|
|
69
|
+
session.create_object(name="Chest", position=(2, 1), passive_description="...")
|
|
70
|
+
prompt = session.build_prompt()
|
|
71
|
+
result = session.run_compound_turn(AgentCompoundTurn(...))
|
|
72
|
+
save_doc = session.to_save_dict()
|
|
73
|
+
restored = Session.from_snapshot(save_doc)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See [documentation](docs/README.md) and [minimal-server](examples/minimal-server/).
|
|
77
|
+
|
|
78
|
+
## Environment
|
|
79
|
+
|
|
80
|
+
Copy [`.env.example`](.env.example) to `.env` and set `OPENROUTER_API_KEY` for LLM turns. Optional `OPENROUTER_MODEL` (default `deepseek/deepseek-v4-flash`). Manual commands work without a key.
|
|
81
|
+
|
|
82
|
+
realm-studio **Settings** (gear icon) can set API key and model **in memory for the current server process only** — nothing is written to disk.
|
|
83
|
+
|
|
84
|
+
## V0.7.0 highlights
|
|
85
|
+
|
|
86
|
+
- **Public API** — expanded `realm_fabric` exports (lorebooks, prompt blocks, `ObjectAction`, `WorldMutationResult`, memory registration)
|
|
87
|
+
- **Typed world API** — `session.create_object()`, `create_agent()`, `edit_object()`, areas, actions — no CLI strings in app code
|
|
88
|
+
- **minimal-server** — thin FastAPI reference at `examples/minimal-server/`
|
|
89
|
+
- **Docs** — [docs/README.md](docs/README.md)
|
|
90
|
+
- **V0.7.1** — engine follow-ups from external demo (demo app **0.1.0**+ in its own repo)
|
|
91
|
+
|
|
92
|
+
## V0.6.1 highlights
|
|
93
|
+
|
|
94
|
+
- **Pluggable handlers** — `register_interaction_handler()`; `ObjectAction.handler_id` + `handler_params`
|
|
95
|
+
- **Reference handlers** — `delete_self`, `random_move_self`, `move_area` in `examples/reference_handlers/` (CLI + realm-studio register at startup)
|
|
96
|
+
- **Interacts + triggers** — same handler surface for LLM interacts and path-step triggers
|
|
97
|
+
- **Saves** — `snapshot_version: 4` (v1–v3 import supported; `effects` migrates to handlers)
|
|
98
|
+
- **Breaking** — CLI `effect` → `handler`; `effects` command → `handlers` (alias kept)
|
|
99
|
+
|
|
100
|
+
## V0.6.0 highlights
|
|
101
|
+
|
|
102
|
+
- **Movement blocking** — objects block tiles by default; BFS pathfinding when `move_speed` is set
|
|
103
|
+
- **Interact pathing** — compound `interact` paths toward the object (replaces explicit `move` that turn)
|
|
104
|
+
- **Passive vision** — look guidance and in-range interactions merged into one prompt slot
|
|
105
|
+
- **Multi-tile objects** — `width` / `height` footprints; range uses nearest footprint tile
|
|
106
|
+
- **Hidden objects + triggers** — GM-only placements; engine-fired triggers on path steps (`Session.emit_area_event`)
|
|
107
|
+
- **Saves** — `snapshot_version: 3` (v1–v2 import still supported)
|
|
108
|
+
- **realm-studio** — footprint overlay, hidden-trigger wizard, collapsible create/edit modals, `private_data` for custom apps
|
|
109
|
+
|
|
110
|
+
## Custom memory modules (V0.4.6)
|
|
111
|
+
|
|
112
|
+
Load `.py` modules at runtime before create-agent or session import:
|
|
113
|
+
|
|
114
|
+
```text
|
|
115
|
+
add-memory-module path\to\my_module.py
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Saves store `module_id` + state only (no bundled source). Import **fails** if a save references a module that is not loaded. Example: [examples/custom_memory/](examples/custom_memory/).
|
|
119
|
+
|
|
120
|
+
## Lorebooks (V0.5.0)
|
|
121
|
+
|
|
122
|
+
Load SillyTavern-style `.json` lorebooks into the session (CLI `load-lorebook` or realm-studio **Lorebooks** tab). Add a `lorebook` prompt block (per book) in Prompt layout to inject matched world info. Not included in the default prompt layout.
|
|
123
|
+
|
|
124
|
+
## CLI reference
|
|
125
|
+
|
|
126
|
+
Full command list, world editing, blocking, hidden objects, triggers, and compound-turn examples: [docs/guides/cli.md](docs/guides/cli.md).
|
|
127
|
+
|
|
128
|
+
## Tests
|
|
129
|
+
|
|
130
|
+
```powershell
|
|
131
|
+
# Engine (repo root)
|
|
132
|
+
uv run pytest
|
|
133
|
+
|
|
134
|
+
# realm-studio
|
|
135
|
+
cd examples\web\realm-studio
|
|
136
|
+
uv run pytest
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
No API key or network required — LLM calls are mocked in tests.
|
|
140
|
+
|
|
141
|
+
## Documentation
|
|
142
|
+
|
|
143
|
+
Start at **[docs/README.md](docs/README.md)** — guides, API overview, and changelog index.
|
|
144
|
+
|
|
145
|
+
| Doc | Topic |
|
|
146
|
+
|-----|--------|
|
|
147
|
+
| [Building on Realm-Fabric](docs/guides/building-on-realm-fabric.md) | App integration (typed API, hosting) |
|
|
148
|
+
| [CLI reference](docs/guides/cli.md) | `realm` stepper commands |
|
|
149
|
+
| [V0.7.0 changelog](docs/changelog/v0.7.0-changelog.md) | Platform SDK, minimal-server |
|
|
150
|
+
| [Roadmap](docs/ROADMAP.md) | Version plans |
|
|
151
|
+
| [realm-studio](examples/web/realm-studio/README.md) | Full GM reference UI |
|
|
152
|
+
| [Long-term goals](LONG_TERM_GOALS.md) | Aspirational features |
|
|
153
|
+
|
|
154
|
+
Older version notes: [changelog index](docs/changelog/README.md).
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Realm Fabric
|
|
2
|
+
|
|
3
|
+
Grid-based LLM agent simulation engine: multi-area worlds, compound turns (move → look → speak → interact/emote), pluggable memory modules, and a stable `realm_fabric` library API. The `realm` CLI and [realm-studio](examples/web/realm-studio) are reference clients — apps build on the engine with their own UI and scenarios.
|
|
4
|
+
|
|
5
|
+
**License:** [MIT](LICENSE) — open source.
|
|
6
|
+
|
|
7
|
+
**Current version:** **V0.7.0** (`0.7.0` in `pyproject.toml`) — stable `realm_fabric` exports, typed `Session` world API, [documentation](docs/README.md), and [minimal-server](examples/minimal-server/). **0.7.1** on this repo is for engine follow-ups from the external demo; the demo itself will version from **0.1.0** in its own repository.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```powershell
|
|
12
|
+
# Engine + CLI
|
|
13
|
+
cd path\to\Realm-Fabric
|
|
14
|
+
uv sync
|
|
15
|
+
uv run realm
|
|
16
|
+
|
|
17
|
+
# Example web UI
|
|
18
|
+
cd examples\web\realm-studio
|
|
19
|
+
uv sync
|
|
20
|
+
copy ..\..\..\.env.example .env # optional; or use Settings gear in the UI
|
|
21
|
+
uv run realm-studio
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
On Windows, if Smart App Control blocks `uv run realm-studio`, use:
|
|
25
|
+
|
|
26
|
+
```powershell
|
|
27
|
+
uv run python -m backend.main
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Open [http://127.0.0.1:8765](http://127.0.0.1:8765). See [realm-studio README](examples/web/realm-studio/README.md).
|
|
31
|
+
|
|
32
|
+
## Library API
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from realm_fabric import Session, load_profile, AgentCompoundTurn
|
|
36
|
+
|
|
37
|
+
session = Session.from_profile(load_profile("default_compound"))
|
|
38
|
+
session.create_agent(name="Scout", position=(0, 0), personality="...")
|
|
39
|
+
session.create_object(name="Chest", position=(2, 1), passive_description="...")
|
|
40
|
+
prompt = session.build_prompt()
|
|
41
|
+
result = session.run_compound_turn(AgentCompoundTurn(...))
|
|
42
|
+
save_doc = session.to_save_dict()
|
|
43
|
+
restored = Session.from_snapshot(save_doc)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
See [documentation](docs/README.md) and [minimal-server](examples/minimal-server/).
|
|
47
|
+
|
|
48
|
+
## Environment
|
|
49
|
+
|
|
50
|
+
Copy [`.env.example`](.env.example) to `.env` and set `OPENROUTER_API_KEY` for LLM turns. Optional `OPENROUTER_MODEL` (default `deepseek/deepseek-v4-flash`). Manual commands work without a key.
|
|
51
|
+
|
|
52
|
+
realm-studio **Settings** (gear icon) can set API key and model **in memory for the current server process only** — nothing is written to disk.
|
|
53
|
+
|
|
54
|
+
## V0.7.0 highlights
|
|
55
|
+
|
|
56
|
+
- **Public API** — expanded `realm_fabric` exports (lorebooks, prompt blocks, `ObjectAction`, `WorldMutationResult`, memory registration)
|
|
57
|
+
- **Typed world API** — `session.create_object()`, `create_agent()`, `edit_object()`, areas, actions — no CLI strings in app code
|
|
58
|
+
- **minimal-server** — thin FastAPI reference at `examples/minimal-server/`
|
|
59
|
+
- **Docs** — [docs/README.md](docs/README.md)
|
|
60
|
+
- **V0.7.1** — engine follow-ups from external demo (demo app **0.1.0**+ in its own repo)
|
|
61
|
+
|
|
62
|
+
## V0.6.1 highlights
|
|
63
|
+
|
|
64
|
+
- **Pluggable handlers** — `register_interaction_handler()`; `ObjectAction.handler_id` + `handler_params`
|
|
65
|
+
- **Reference handlers** — `delete_self`, `random_move_self`, `move_area` in `examples/reference_handlers/` (CLI + realm-studio register at startup)
|
|
66
|
+
- **Interacts + triggers** — same handler surface for LLM interacts and path-step triggers
|
|
67
|
+
- **Saves** — `snapshot_version: 4` (v1–v3 import supported; `effects` migrates to handlers)
|
|
68
|
+
- **Breaking** — CLI `effect` → `handler`; `effects` command → `handlers` (alias kept)
|
|
69
|
+
|
|
70
|
+
## V0.6.0 highlights
|
|
71
|
+
|
|
72
|
+
- **Movement blocking** — objects block tiles by default; BFS pathfinding when `move_speed` is set
|
|
73
|
+
- **Interact pathing** — compound `interact` paths toward the object (replaces explicit `move` that turn)
|
|
74
|
+
- **Passive vision** — look guidance and in-range interactions merged into one prompt slot
|
|
75
|
+
- **Multi-tile objects** — `width` / `height` footprints; range uses nearest footprint tile
|
|
76
|
+
- **Hidden objects + triggers** — GM-only placements; engine-fired triggers on path steps (`Session.emit_area_event`)
|
|
77
|
+
- **Saves** — `snapshot_version: 3` (v1–v2 import still supported)
|
|
78
|
+
- **realm-studio** — footprint overlay, hidden-trigger wizard, collapsible create/edit modals, `private_data` for custom apps
|
|
79
|
+
|
|
80
|
+
## Custom memory modules (V0.4.6)
|
|
81
|
+
|
|
82
|
+
Load `.py` modules at runtime before create-agent or session import:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
add-memory-module path\to\my_module.py
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Saves store `module_id` + state only (no bundled source). Import **fails** if a save references a module that is not loaded. Example: [examples/custom_memory/](examples/custom_memory/).
|
|
89
|
+
|
|
90
|
+
## Lorebooks (V0.5.0)
|
|
91
|
+
|
|
92
|
+
Load SillyTavern-style `.json` lorebooks into the session (CLI `load-lorebook` or realm-studio **Lorebooks** tab). Add a `lorebook` prompt block (per book) in Prompt layout to inject matched world info. Not included in the default prompt layout.
|
|
93
|
+
|
|
94
|
+
## CLI reference
|
|
95
|
+
|
|
96
|
+
Full command list, world editing, blocking, hidden objects, triggers, and compound-turn examples: [docs/guides/cli.md](docs/guides/cli.md).
|
|
97
|
+
|
|
98
|
+
## Tests
|
|
99
|
+
|
|
100
|
+
```powershell
|
|
101
|
+
# Engine (repo root)
|
|
102
|
+
uv run pytest
|
|
103
|
+
|
|
104
|
+
# realm-studio
|
|
105
|
+
cd examples\web\realm-studio
|
|
106
|
+
uv run pytest
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
No API key or network required — LLM calls are mocked in tests.
|
|
110
|
+
|
|
111
|
+
## Documentation
|
|
112
|
+
|
|
113
|
+
Start at **[docs/README.md](docs/README.md)** — guides, API overview, and changelog index.
|
|
114
|
+
|
|
115
|
+
| Doc | Topic |
|
|
116
|
+
|-----|--------|
|
|
117
|
+
| [Building on Realm-Fabric](docs/guides/building-on-realm-fabric.md) | App integration (typed API, hosting) |
|
|
118
|
+
| [CLI reference](docs/guides/cli.md) | `realm` stepper commands |
|
|
119
|
+
| [V0.7.0 changelog](docs/changelog/v0.7.0-changelog.md) | Platform SDK, minimal-server |
|
|
120
|
+
| [Roadmap](docs/ROADMAP.md) | Version plans |
|
|
121
|
+
| [realm-studio](examples/web/realm-studio/README.md) | Full GM reference UI |
|
|
122
|
+
| [Long-term goals](LONG_TERM_GOALS.md) | Aspirational features |
|
|
123
|
+
|
|
124
|
+
Older version notes: [changelog index](docs/changelog/README.md).
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Example 1: Move, look, and speak
|
|
2
|
+
|
|
3
|
+
Context:
|
|
4
|
+
Passive Vision:
|
|
5
|
+
You are at (1, 1).
|
|
6
|
+
Detail marked [?] can be examined with look.
|
|
7
|
+
Ceramic Ball (obj_ball_01), (2, 2) - [?]
|
|
8
|
+
- kick (range 1)
|
|
9
|
+
Wooden Sign (obj_sign_01), (2, 4) - [?] A simple wooden sign on the wall.
|
|
10
|
+
|
|
11
|
+
Output:
|
|
12
|
+
{
|
|
13
|
+
"reasoning": "The ball is at (2, 2). I will move closer, examine it, and comment.",
|
|
14
|
+
"move": "2,3",
|
|
15
|
+
"look": "obj_ball_01",
|
|
16
|
+
"say": "Interesting ball.",
|
|
17
|
+
"action": "none",
|
|
18
|
+
"target": null,
|
|
19
|
+
"verb": null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Example 2: Stay in place and speak
|
|
23
|
+
|
|
24
|
+
Context:
|
|
25
|
+
Passive Vision:
|
|
26
|
+
You are at (2, 2).
|
|
27
|
+
Detail marked [?] can be examined with look.
|
|
28
|
+
Ceramic Ball (obj_ball_01), (2, 2) - [?]
|
|
29
|
+
- kick (range 1)
|
|
30
|
+
Wooden Sign (obj_sign_01), (2, 4) - [?] A simple wooden sign on the wall.
|
|
31
|
+
|
|
32
|
+
Output:
|
|
33
|
+
{
|
|
34
|
+
"reasoning": "Nothing new to examine. I will speak from here.",
|
|
35
|
+
"move": null,
|
|
36
|
+
"look": null,
|
|
37
|
+
"say": "Hello, room.",
|
|
38
|
+
"action": "none",
|
|
39
|
+
"target": null,
|
|
40
|
+
"verb": null
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Example 3: Move only
|
|
44
|
+
|
|
45
|
+
Context:
|
|
46
|
+
Passive Vision:
|
|
47
|
+
You are at (1, 1).
|
|
48
|
+
Detail marked [?] can be examined with look.
|
|
49
|
+
Ceramic Ball (obj_ball_01), (2, 2) - [?]
|
|
50
|
+
- kick (range 1)
|
|
51
|
+
Wooden Sign (obj_sign_01), (2, 4) - [?] A simple wooden sign on the wall.
|
|
52
|
+
You may move to any coordinate (x, y) where x is an integer from 0 to 4 and y is an integer from 0 to 4.
|
|
53
|
+
|
|
54
|
+
Output:
|
|
55
|
+
{
|
|
56
|
+
"reasoning": "The sign is at (2, 4). I will move closer.",
|
|
57
|
+
"move": "2,3",
|
|
58
|
+
"look": null,
|
|
59
|
+
"say": null,
|
|
60
|
+
"action": "none",
|
|
61
|
+
"target": null,
|
|
62
|
+
"verb": null
|
|
63
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "realm-fabric"
|
|
3
|
+
version = "0.7.0"
|
|
4
|
+
description = "Grid-based LLM agent simulation engine — Session API, multi-area worlds, tactical movement, compound turns, pluggable memory"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "DaveH-Ghost", email = "davidhall.a27@gmail.com" },
|
|
10
|
+
]
|
|
11
|
+
keywords = [
|
|
12
|
+
"llm",
|
|
13
|
+
"agents",
|
|
14
|
+
"simulation",
|
|
15
|
+
"game-engine",
|
|
16
|
+
"grid",
|
|
17
|
+
"roleplay",
|
|
18
|
+
]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Development Status :: 4 - Beta",
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Topic :: Games/Entertainment",
|
|
28
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
29
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
30
|
+
]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"pydantic",
|
|
33
|
+
"openai",
|
|
34
|
+
"rich",
|
|
35
|
+
"python-dotenv",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/DaveH-Ghost/Realm-Fabric"
|
|
40
|
+
Documentation = "https://github.com/DaveH-Ghost/Realm-Fabric/blob/main/docs/README.md"
|
|
41
|
+
Repository = "https://github.com/DaveH-Ghost/Realm-Fabric"
|
|
42
|
+
Issues = "https://github.com/DaveH-Ghost/Realm-Fabric/issues"
|
|
43
|
+
Changelog = "https://github.com/DaveH-Ghost/Realm-Fabric/blob/main/docs/changelog/README.md"
|
|
44
|
+
|
|
45
|
+
[dependency-groups]
|
|
46
|
+
dev = [
|
|
47
|
+
"pytest>=9.0.3",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[tool.pytest.ini_options]
|
|
51
|
+
pythonpath = ["."]
|
|
52
|
+
testpaths = ["tests"]
|
|
53
|
+
addopts = "-q"
|
|
54
|
+
|
|
55
|
+
[project.scripts]
|
|
56
|
+
realm = "src.main:main"
|
|
57
|
+
|
|
58
|
+
[build-system]
|
|
59
|
+
requires = ["hatchling"]
|
|
60
|
+
build-backend = "hatchling.build"
|
|
61
|
+
|
|
62
|
+
[tool.hatch.build]
|
|
63
|
+
packages = ["src", "realm_fabric"]
|
|
64
|
+
|
|
65
|
+
[tool.hatch.build.targets.wheel]
|
|
66
|
+
force-include = { "profiles" = "profiles" }
|
|
67
|
+
|
|
68
|
+
[tool.hatch.build.targets.sdist]
|
|
69
|
+
include = [
|
|
70
|
+
"/profiles",
|
|
71
|
+
]
|
|
72
|
+
force-include = { "profiles" = "profiles" }
|
|
73
|
+
|
|
74
|
+
[tool.uv]
|
|
75
|
+
package = true
|