campaign-rpg-engine 1.0.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.
Files changed (82) hide show
  1. campaign_rpg_engine-1.0.0/.gitignore +156 -0
  2. campaign_rpg_engine-1.0.0/LICENSE +21 -0
  3. campaign_rpg_engine-1.0.0/PKG-INFO +114 -0
  4. campaign_rpg_engine-1.0.0/README.md +84 -0
  5. campaign_rpg_engine-1.0.0/campaign_rpg_engine/__init__.py +210 -0
  6. campaign_rpg_engine-1.0.0/campaign_rpg_engine/action_outcome.py +19 -0
  7. campaign_rpg_engine-1.0.0/campaign_rpg_engine/actions/__init__.py +15 -0
  8. campaign_rpg_engine-1.0.0/campaign_rpg_engine/actions/emote.py +24 -0
  9. campaign_rpg_engine-1.0.0/campaign_rpg_engine/actions/interact.py +621 -0
  10. campaign_rpg_engine-1.0.0/campaign_rpg_engine/actions/move.py +350 -0
  11. campaign_rpg_engine-1.0.0/campaign_rpg_engine/actions/speak.py +19 -0
  12. campaign_rpg_engine-1.0.0/campaign_rpg_engine/agent.py +98 -0
  13. campaign_rpg_engine-1.0.0/campaign_rpg_engine/area.py +384 -0
  14. campaign_rpg_engine-1.0.0/campaign_rpg_engine/area_edit.py +1308 -0
  15. campaign_rpg_engine-1.0.0/campaign_rpg_engine/area_edit_parse.py +38 -0
  16. campaign_rpg_engine-1.0.0/campaign_rpg_engine/area_event.py +29 -0
  17. campaign_rpg_engine-1.0.0/campaign_rpg_engine/compound_arg_parse.py +110 -0
  18. campaign_rpg_engine-1.0.0/campaign_rpg_engine/coordinates.py +54 -0
  19. campaign_rpg_engine-1.0.0/campaign_rpg_engine/emote_phrasing.py +40 -0
  20. campaign_rpg_engine-1.0.0/campaign_rpg_engine/game_profile.py +177 -0
  21. campaign_rpg_engine-1.0.0/campaign_rpg_engine/grid.py +9 -0
  22. campaign_rpg_engine-1.0.0/campaign_rpg_engine/interact_templates.py +71 -0
  23. campaign_rpg_engine-1.0.0/campaign_rpg_engine/interaction_handlers/__init__.py +24 -0
  24. campaign_rpg_engine-1.0.0/campaign_rpg_engine/interaction_handlers/base.py +27 -0
  25. campaign_rpg_engine-1.0.0/campaign_rpg_engine/interaction_handlers/registry.py +111 -0
  26. campaign_rpg_engine-1.0.0/campaign_rpg_engine/llm/__init__.py +4 -0
  27. campaign_rpg_engine-1.0.0/campaign_rpg_engine/llm/client.py +143 -0
  28. campaign_rpg_engine-1.0.0/campaign_rpg_engine/llm/memory_summary.py +88 -0
  29. campaign_rpg_engine-1.0.0/campaign_rpg_engine/llm/prompt.py +44 -0
  30. campaign_rpg_engine-1.0.0/campaign_rpg_engine/llm/prompt_context.py +258 -0
  31. campaign_rpg_engine-1.0.0/campaign_rpg_engine/llm/schemas.py +149 -0
  32. campaign_rpg_engine-1.0.0/campaign_rpg_engine/llm/text_truncation.py +111 -0
  33. campaign_rpg_engine-1.0.0/campaign_rpg_engine/llm/token_estimate.py +16 -0
  34. campaign_rpg_engine-1.0.0/campaign_rpg_engine/llm/types.py +21 -0
  35. campaign_rpg_engine-1.0.0/campaign_rpg_engine/log_utils/__init__.py +14 -0
  36. campaign_rpg_engine-1.0.0/campaign_rpg_engine/log_utils/logger.py +152 -0
  37. campaign_rpg_engine-1.0.0/campaign_rpg_engine/lorebook/__init__.py +29 -0
  38. campaign_rpg_engine-1.0.0/campaign_rpg_engine/lorebook/factory.py +37 -0
  39. campaign_rpg_engine-1.0.0/campaign_rpg_engine/lorebook/import_st.py +70 -0
  40. campaign_rpg_engine-1.0.0/campaign_rpg_engine/lorebook/listing.py +17 -0
  41. campaign_rpg_engine-1.0.0/campaign_rpg_engine/lorebook/matcher.py +111 -0
  42. campaign_rpg_engine-1.0.0/campaign_rpg_engine/lorebook/models.py +123 -0
  43. campaign_rpg_engine-1.0.0/campaign_rpg_engine/lorebook/scan_config.py +90 -0
  44. campaign_rpg_engine-1.0.0/campaign_rpg_engine/lorebook/st_defaults.py +99 -0
  45. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory.py +156 -0
  46. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/__init__.py +28 -0
  47. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/base.py +85 -0
  48. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/consolidation_runner.py +179 -0
  49. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/formatting/__init__.py +34 -0
  50. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/formatting/common.py +93 -0
  51. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/formatting/salient.py +34 -0
  52. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/formatting/summary.py +32 -0
  53. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/loader.py +106 -0
  54. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/recent_turns.py +100 -0
  55. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/registry.py +267 -0
  56. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/rolling_summary.py +297 -0
  57. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/salient_turns.py +286 -0
  58. campaign_rpg_engine-1.0.0/campaign_rpg_engine/memory_modules/serialization.py +101 -0
  59. campaign_rpg_engine-1.0.0/campaign_rpg_engine/move_target.py +288 -0
  60. campaign_rpg_engine-1.0.0/campaign_rpg_engine/object.py +135 -0
  61. campaign_rpg_engine-1.0.0/campaign_rpg_engine/object_action.py +42 -0
  62. campaign_rpg_engine-1.0.0/campaign_rpg_engine/observations.py +121 -0
  63. campaign_rpg_engine-1.0.0/campaign_rpg_engine/occupancy.py +244 -0
  64. campaign_rpg_engine-1.0.0/campaign_rpg_engine/pathfinding.py +155 -0
  65. campaign_rpg_engine-1.0.0/campaign_rpg_engine/pathing.py +57 -0
  66. campaign_rpg_engine-1.0.0/campaign_rpg_engine/perception.py +431 -0
  67. campaign_rpg_engine-1.0.0/campaign_rpg_engine/prompt_blocks.py +462 -0
  68. campaign_rpg_engine-1.0.0/campaign_rpg_engine/prompt_template.py +57 -0
  69. campaign_rpg_engine-1.0.0/campaign_rpg_engine/reserved_names.py +80 -0
  70. campaign_rpg_engine-1.0.0/campaign_rpg_engine/session.py +1149 -0
  71. campaign_rpg_engine-1.0.0/campaign_rpg_engine/session_area_edit.py +254 -0
  72. campaign_rpg_engine-1.0.0/campaign_rpg_engine/session_persistence.py +351 -0
  73. campaign_rpg_engine-1.0.0/campaign_rpg_engine/simulation.py +288 -0
  74. campaign_rpg_engine-1.0.0/campaign_rpg_engine/snapshot.py +213 -0
  75. campaign_rpg_engine-1.0.0/campaign_rpg_engine/triggers.py +119 -0
  76. campaign_rpg_engine-1.0.0/campaign_rpg_engine/turn_record.py +33 -0
  77. campaign_rpg_engine-1.0.0/campaign_rpg_engine/utils/__init__.py +6 -0
  78. campaign_rpg_engine-1.0.0/campaign_rpg_engine/vision_bearing.py +94 -0
  79. campaign_rpg_engine-1.0.0/campaign_rpg_engine/world_edit_api.py +460 -0
  80. campaign_rpg_engine-1.0.0/profiles/default_compound/few_shots.txt +63 -0
  81. campaign_rpg_engine-1.0.0/profiles/default_compound/template.txt +17 -0
  82. campaign_rpg_engine-1.0.0/pyproject.toml +74 -0
@@ -0,0 +1,156 @@
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
@@ -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,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: campaign-rpg-engine
3
+ Version: 1.0.0
4
+ Summary: CampAIgn — map-based LLM RPG simulation engine (Session API, multi-area worlds, compound turns)
5
+ Project-URL: Homepage, https://github.com/DaveH-Ghost/CampAIgn-RPG-Engine
6
+ Project-URL: Documentation, https://github.com/DaveH-Ghost/CampAIgn-RPG-Engine/blob/main/docs/README.md
7
+ Project-URL: Repository, https://github.com/DaveH-Ghost/CampAIgn-RPG-Engine
8
+ Project-URL: Issues, https://github.com/DaveH-Ghost/CampAIgn-RPG-Engine/issues
9
+ Project-URL: Changelog, https://github.com/DaveH-Ghost/CampAIgn-RPG-Engine/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,campaign,game-engine,grid,llm,roleplay,rpg,simulation
14
+ Classifier: Development Status :: 5 - Production/Stable
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
+ # CampAIgn RPG Engine
32
+
33
+ Grid-based LLM agent simulation engine: multi-area worlds, compound turns (move → look → speak → interact/emote), pluggable memory modules, and a stable **`campaign_rpg_engine`** library API. Build your own UI and scenarios on the engine; use [CampAIgn-RPG-Studio](https://github.com/DaveH-Ghost/CampAIgn-RPG-Studio) as a full GM reference app.
34
+
35
+ **License:** [MIT](LICENSE) — open source.
36
+
37
+ **Current version:** **1.0.0** — library-first package (`campaign_rpg_engine` only; no CLI). See [Migration from 0.7](docs/MIGRATION-0.7-to-1.0.md) and the [changelog index](docs/changelog/README.md).
38
+
39
+ ## Quick start
40
+
41
+ ```powershell
42
+ cd path\to\CampAIgn-RPG-Engine
43
+ uv sync
44
+ uv run pytest
45
+ ```
46
+
47
+ ```python
48
+ from campaign_rpg_engine import Session, load_profile, AgentCompoundTurn
49
+
50
+ session = Session.from_profile(load_profile("default_compound"))
51
+ session.create_agent(name="Scout", position=(0, 0), personality="Curious.")
52
+ session.create_object(name="Chest", position=(2, 1), passive_description="An old chest.")
53
+ prompt = session.build_prompt()
54
+ result = session.run_compound_turn(
55
+ AgentCompoundTurn(reasoning="look around", action="none"),
56
+ )
57
+ ```
58
+
59
+ **GM web UI:** clone [CampAIgn-RPG-Studio](https://github.com/DaveH-Ghost/CampAIgn-RPG-Studio) (separate GitHub repo):
60
+
61
+ ```powershell
62
+ cd path\to\CampAIgn-RPG-Studio
63
+ uv sync
64
+ copy .env.example .env # optional; or use Settings gear in the UI
65
+ uv run campaign-rpg-studio
66
+ ```
67
+
68
+ On Windows, if Smart App Control blocks `uv run campaign-rpg-studio`, use `uv run python -m backend.main`. Open [http://127.0.0.1:8765](http://127.0.0.1:8765).
69
+
70
+ ## Environment
71
+
72
+ Copy [`.env.example`](.env.example) to `.env` and set `OPENROUTER_API_KEY` for LLM turns. Optional `OPENROUTER_MODEL` (default `deepseek/deepseek-v4-flash`). Engine tests mock the LLM — no key required for `uv run pytest`.
73
+
74
+ CampAIgn-RPG-Studio **Settings** (gear icon) can set API key and model **in memory for the current server process only** — nothing is written to disk.
75
+
76
+ ## Custom memory modules
77
+
78
+ Register `.py` modules at process startup before creating agents or loading saves:
79
+
80
+ ```python
81
+ from campaign_rpg_engine import register_memory_module_from_path
82
+
83
+ register_memory_module_from_path("path/to/my_module.py")
84
+ session.create_agent(..., memory_module="my_module_id")
85
+ ```
86
+
87
+ Saves store `module_id` + state only (no bundled source). Import **fails** if a save references a module that is not loaded. Sample module and upload UI: [CampAIgn-RPG-Studio `fixtures/custom_memory/`](https://github.com/DaveH-Ghost/CampAIgn-RPG-Studio/tree/main/fixtures/custom_memory).
88
+
89
+ ## Lorebooks
90
+
91
+ Load SillyTavern-style `.json` lorebooks via `session.load_lorebook_from_path(...)` or CampAIgn-RPG-Studio **Lorebooks** tab. Add a `lorebook` prompt block in Prompt layout to inject matched world info. Not included in the default prompt layout.
92
+
93
+ ## Tests
94
+
95
+ ```powershell
96
+ uv run pytest
97
+ ```
98
+
99
+ CampAIgn-RPG-Studio API tests live in the [CampAIgn-RPG-Studio](https://github.com/DaveH-Ghost/CampAIgn-RPG-Studio) repo.
100
+
101
+ ## Documentation
102
+
103
+ Start at **[docs/README.md](docs/README.md)** — guides, API overview, and changelog index.
104
+
105
+ | Doc | Topic |
106
+ |-----|--------|
107
+ | [Building on CampAIgn-RPG-Engine](docs/guides/building-on-campaign-rpg-engine.md) | App integration (typed API, hosting) |
108
+ | [API reference](docs/guides/api-reference.md) | `campaign_rpg_engine` exports and Session methods |
109
+ | [Migration realm-fabric → campaign-rpg-engine](docs/MIGRATION-realm-fabric-to-campaign-rpg-engine.md) | Rename from Realm-Fabric / `realm_fabric` |
110
+ | [CampAIgn-RPG-Studio](https://github.com/DaveH-Ghost/CampAIgn-RPG-Studio) | Full GM reference UI (GitHub) |
111
+ | [Roadmap](docs/ROADMAP.md) | Version plans |
112
+ | [Long-term goals](LONG_TERM_GOALS.md) | Aspirational features |
113
+
114
+ Older version notes: [changelog index](docs/changelog/README.md).
@@ -0,0 +1,84 @@
1
+ # CampAIgn RPG Engine
2
+
3
+ Grid-based LLM agent simulation engine: multi-area worlds, compound turns (move → look → speak → interact/emote), pluggable memory modules, and a stable **`campaign_rpg_engine`** library API. Build your own UI and scenarios on the engine; use [CampAIgn-RPG-Studio](https://github.com/DaveH-Ghost/CampAIgn-RPG-Studio) as a full GM reference app.
4
+
5
+ **License:** [MIT](LICENSE) — open source.
6
+
7
+ **Current version:** **1.0.0** — library-first package (`campaign_rpg_engine` only; no CLI). See [Migration from 0.7](docs/MIGRATION-0.7-to-1.0.md) and the [changelog index](docs/changelog/README.md).
8
+
9
+ ## Quick start
10
+
11
+ ```powershell
12
+ cd path\to\CampAIgn-RPG-Engine
13
+ uv sync
14
+ uv run pytest
15
+ ```
16
+
17
+ ```python
18
+ from campaign_rpg_engine import Session, load_profile, AgentCompoundTurn
19
+
20
+ session = Session.from_profile(load_profile("default_compound"))
21
+ session.create_agent(name="Scout", position=(0, 0), personality="Curious.")
22
+ session.create_object(name="Chest", position=(2, 1), passive_description="An old chest.")
23
+ prompt = session.build_prompt()
24
+ result = session.run_compound_turn(
25
+ AgentCompoundTurn(reasoning="look around", action="none"),
26
+ )
27
+ ```
28
+
29
+ **GM web UI:** clone [CampAIgn-RPG-Studio](https://github.com/DaveH-Ghost/CampAIgn-RPG-Studio) (separate GitHub repo):
30
+
31
+ ```powershell
32
+ cd path\to\CampAIgn-RPG-Studio
33
+ uv sync
34
+ copy .env.example .env # optional; or use Settings gear in the UI
35
+ uv run campaign-rpg-studio
36
+ ```
37
+
38
+ On Windows, if Smart App Control blocks `uv run campaign-rpg-studio`, use `uv run python -m backend.main`. Open [http://127.0.0.1:8765](http://127.0.0.1:8765).
39
+
40
+ ## Environment
41
+
42
+ Copy [`.env.example`](.env.example) to `.env` and set `OPENROUTER_API_KEY` for LLM turns. Optional `OPENROUTER_MODEL` (default `deepseek/deepseek-v4-flash`). Engine tests mock the LLM — no key required for `uv run pytest`.
43
+
44
+ CampAIgn-RPG-Studio **Settings** (gear icon) can set API key and model **in memory for the current server process only** — nothing is written to disk.
45
+
46
+ ## Custom memory modules
47
+
48
+ Register `.py` modules at process startup before creating agents or loading saves:
49
+
50
+ ```python
51
+ from campaign_rpg_engine import register_memory_module_from_path
52
+
53
+ register_memory_module_from_path("path/to/my_module.py")
54
+ session.create_agent(..., memory_module="my_module_id")
55
+ ```
56
+
57
+ Saves store `module_id` + state only (no bundled source). Import **fails** if a save references a module that is not loaded. Sample module and upload UI: [CampAIgn-RPG-Studio `fixtures/custom_memory/`](https://github.com/DaveH-Ghost/CampAIgn-RPG-Studio/tree/main/fixtures/custom_memory).
58
+
59
+ ## Lorebooks
60
+
61
+ Load SillyTavern-style `.json` lorebooks via `session.load_lorebook_from_path(...)` or CampAIgn-RPG-Studio **Lorebooks** tab. Add a `lorebook` prompt block in Prompt layout to inject matched world info. Not included in the default prompt layout.
62
+
63
+ ## Tests
64
+
65
+ ```powershell
66
+ uv run pytest
67
+ ```
68
+
69
+ CampAIgn-RPG-Studio API tests live in the [CampAIgn-RPG-Studio](https://github.com/DaveH-Ghost/CampAIgn-RPG-Studio) repo.
70
+
71
+ ## Documentation
72
+
73
+ Start at **[docs/README.md](docs/README.md)** — guides, API overview, and changelog index.
74
+
75
+ | Doc | Topic |
76
+ |-----|--------|
77
+ | [Building on CampAIgn-RPG-Engine](docs/guides/building-on-campaign-rpg-engine.md) | App integration (typed API, hosting) |
78
+ | [API reference](docs/guides/api-reference.md) | `campaign_rpg_engine` exports and Session methods |
79
+ | [Migration realm-fabric → campaign-rpg-engine](docs/MIGRATION-realm-fabric-to-campaign-rpg-engine.md) | Rename from Realm-Fabric / `realm_fabric` |
80
+ | [CampAIgn-RPG-Studio](https://github.com/DaveH-Ghost/CampAIgn-RPG-Studio) | Full GM reference UI (GitHub) |
81
+ | [Roadmap](docs/ROADMAP.md) | Version plans |
82
+ | [Long-term goals](LONG_TERM_GOALS.md) | Aspirational features |
83
+
84
+ Older version notes: [changelog index](docs/changelog/README.md).
@@ -0,0 +1,210 @@
1
+ """
2
+ campaign_rpg_engine — public engine API for CampAIgn-RPG-Engine (1.0.0).
3
+
4
+ Import from this package in application code.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import tomllib
10
+ from pathlib import Path
11
+
12
+ from campaign_rpg_engine.agent import Agent
13
+ from campaign_rpg_engine.area import Area, GridBounds, create_area, create_initial_area
14
+ from campaign_rpg_engine.area_edit import (
15
+ delete_agent_by_id,
16
+ format_agents_list,
17
+ format_full_list,
18
+ format_objects_list,
19
+ parse_position,
20
+ )
21
+ from campaign_rpg_engine.game_profile import GameProfile, default_compound_profile, load_profile
22
+ from campaign_rpg_engine.interact_templates import interact_template_var_help
23
+ from campaign_rpg_engine.llm.client import LLMParseError, get_compound_turn
24
+ from campaign_rpg_engine.llm.prompt_context import PromptContext, build_prompt_context
25
+ from campaign_rpg_engine.llm.schemas import AgentCompoundTurn
26
+ from campaign_rpg_engine.llm.token_estimate import estimate_prompt_tokens
27
+ from campaign_rpg_engine.llm.types import LLMResponse
28
+ from campaign_rpg_engine.lorebook import (
29
+ DEFAULT_LOREBOOK_CHAR_BUDGET,
30
+ Lorebook,
31
+ LoreEntry,
32
+ LorebookScanConfig,
33
+ ST_ENTRY_DEFAULTS,
34
+ build_scan_corpus,
35
+ derive_lorebook_id_from_filename,
36
+ describe_scan_sources,
37
+ load_lorebook_from_dict,
38
+ load_lorebook_from_path,
39
+ match_lorebook_entries,
40
+ new_st_entry_dict,
41
+ render_lorebook,
42
+ with_st_entry_defaults,
43
+ )
44
+ from campaign_rpg_engine.lorebook.factory import create_empty_lorebook
45
+ from campaign_rpg_engine.memory import TurnRecord
46
+ from campaign_rpg_engine.memory_modules.base import MemoryModule
47
+ from campaign_rpg_engine.memory_modules.recent_turns import DEFAULT_WINDOW, MAX_WINDOW, MIN_WINDOW
48
+ from campaign_rpg_engine.memory_modules.registry import (
49
+ clear_custom_memory_registrations,
50
+ default_module_id,
51
+ format_memory_modules_list,
52
+ get_custom_module_metadata,
53
+ loaded_module_ids,
54
+ register_memory_module_from_path,
55
+ register_memory_module_from_source,
56
+ )
57
+ from campaign_rpg_engine.memory_modules.rolling_summary import (
58
+ DEFAULT_MAX_SUMMARY_CHARS,
59
+ DEFAULT_SUMMARY_INTERVAL,
60
+ DEFAULT_SUMMARY_TAIL,
61
+ MAX_MAX_SUMMARY_CHARS,
62
+ MIN_MAX_SUMMARY_CHARS,
63
+ MIN_SUMMARY_INTERVAL,
64
+ MIN_SUMMARY_TAIL,
65
+ RollingSummaryModule,
66
+ )
67
+ from campaign_rpg_engine.memory_modules.salient_turns import (
68
+ DEFAULT_CHAR_BUDGET,
69
+ MAX_CHAR_BUDGET,
70
+ MIN_CHAR_BUDGET,
71
+ )
72
+ from campaign_rpg_engine.object import Object, object_footprint_tiles
73
+ from campaign_rpg_engine.object_action import ActionKind, ObjectAction
74
+ from campaign_rpg_engine.perception import build_passive_vision
75
+ from campaign_rpg_engine.prompt_blocks import (
76
+ PromptBlock,
77
+ default_prompt_blocks,
78
+ enrich_blocks_with_previews,
79
+ prompt_block_catalog,
80
+ prompt_blocks_from_dicts,
81
+ prompt_slot_catalog,
82
+ validate_prompt_blocks,
83
+ )
84
+ from campaign_rpg_engine.session import Session, SessionResult, TurnResult
85
+ from campaign_rpg_engine.session_area_edit import (
86
+ AreaMutationResult,
87
+ delete_area_by_id,
88
+ )
89
+ from campaign_rpg_engine.simulation import run_compound_turn
90
+ from campaign_rpg_engine.session_persistence import build_save_snapshot, load_session_from_snapshot
91
+ from campaign_rpg_engine.interaction_handlers import (
92
+ format_handlers_list,
93
+ get_handler_registration,
94
+ is_handler_registered,
95
+ list_registered_handlers,
96
+ register_interaction_handler,
97
+ run_interaction_handler,
98
+ )
99
+ from campaign_rpg_engine.snapshot import DEFAULT_AREA_ID, build_area_snapshot, build_session_snapshot
100
+ from campaign_rpg_engine.world_edit_api import WorldMutationResult
101
+
102
+ __all__ = [
103
+ "__version__",
104
+ "ActionKind",
105
+ "Agent",
106
+ "AgentCompoundTurn",
107
+ "Area",
108
+ "AreaMutationResult",
109
+ "DEFAULT_AREA_ID",
110
+ "DEFAULT_CHAR_BUDGET",
111
+ "DEFAULT_LOREBOOK_CHAR_BUDGET",
112
+ "DEFAULT_MAX_SUMMARY_CHARS",
113
+ "DEFAULT_SUMMARY_INTERVAL",
114
+ "DEFAULT_SUMMARY_TAIL",
115
+ "DEFAULT_WINDOW",
116
+ "GameProfile",
117
+ "GridBounds",
118
+ "LLMParseError",
119
+ "LLMResponse",
120
+ "Lorebook",
121
+ "LoreEntry",
122
+ "LorebookScanConfig",
123
+ "MAX_CHAR_BUDGET",
124
+ "MAX_MAX_SUMMARY_CHARS",
125
+ "MAX_WINDOW",
126
+ "MemoryModule",
127
+ "MIN_CHAR_BUDGET",
128
+ "MIN_MAX_SUMMARY_CHARS",
129
+ "MIN_SUMMARY_INTERVAL",
130
+ "MIN_SUMMARY_TAIL",
131
+ "MIN_WINDOW",
132
+ "Object",
133
+ "ObjectAction",
134
+ "PromptBlock",
135
+ "PromptContext",
136
+ "RollingSummaryModule",
137
+ "Session",
138
+ "SessionResult",
139
+ "ST_ENTRY_DEFAULTS",
140
+ "TurnRecord",
141
+ "TurnResult",
142
+ "WorldMutationResult",
143
+ "build_area_snapshot",
144
+ "build_passive_vision",
145
+ "build_prompt_context",
146
+ "build_save_snapshot",
147
+ "build_scan_corpus",
148
+ "build_session_snapshot",
149
+ "clear_custom_memory_registrations",
150
+ "create_area",
151
+ "create_empty_lorebook",
152
+ "create_initial_area",
153
+ "default_compound_profile",
154
+ "default_module_id",
155
+ "default_prompt_blocks",
156
+ "delete_area_by_id",
157
+ "derive_lorebook_id_from_filename",
158
+ "describe_scan_sources",
159
+ "enrich_blocks_with_previews",
160
+ "estimate_prompt_tokens",
161
+ "format_agents_list",
162
+ "format_full_list",
163
+ "format_handlers_list",
164
+ "format_memory_modules_list",
165
+ "format_objects_list",
166
+ "get_compound_turn",
167
+ "get_custom_module_metadata",
168
+ "get_handler_registration",
169
+ "interact_template_var_help",
170
+ "is_handler_registered",
171
+ "list_registered_handlers",
172
+ "load_lorebook_from_dict",
173
+ "load_lorebook_from_path",
174
+ "load_profile",
175
+ "load_session_from_snapshot",
176
+ "loaded_module_ids",
177
+ "match_lorebook_entries",
178
+ "new_st_entry_dict",
179
+ "object_footprint_tiles",
180
+ "parse_position",
181
+ "prompt_block_catalog",
182
+ "prompt_blocks_from_dicts",
183
+ "prompt_slot_catalog",
184
+ "register_interaction_handler",
185
+ "register_memory_module_from_path",
186
+ "register_memory_module_from_source",
187
+ "render_lorebook",
188
+ "run_compound_turn",
189
+ "run_interaction_handler",
190
+ "validate_prompt_blocks",
191
+ "with_st_entry_defaults",
192
+ ]
193
+
194
+ _ROOT = Path(__file__).resolve().parent.parent
195
+
196
+
197
+ def _read_version() -> str:
198
+ try:
199
+ from importlib.metadata import version as _pkg_version
200
+
201
+ return _pkg_version("campaign-rpg-engine")
202
+ except Exception:
203
+ pass
204
+ pyproject_path = _ROOT / "pyproject.toml"
205
+ if pyproject_path.is_file():
206
+ return tomllib.loads(pyproject_path.read_text(encoding="utf-8"))["project"]["version"]
207
+ return "0.0.0"
208
+
209
+
210
+ __version__ = _read_version()
@@ -0,0 +1,19 @@
1
+ """Action result types — first-person result for the actor, passive for observers."""
2
+ from __future__ import annotations
3
+
4
+ from dataclasses import dataclass
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class ActionOutcome:
9
+ """Result of executing one action."""
10
+
11
+ result: str
12
+ """First-person feedback for the acting agent (stored in TurnRecord)."""
13
+
14
+ passive_result: str = ""
15
+ """
16
+ Third-person summary for other agents' passive vision.
17
+
18
+ Empty when the action did not succeed or has nothing observable.
19
+ """
@@ -0,0 +1,15 @@
1
+ """
2
+ Actions package.
3
+
4
+ Contains move, speak, and interact implementations. Look is implemented in
5
+ perception.py (perform_look) because it shares vision/memory logic.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from campaign_rpg_engine.actions.emote import emote as do_emote
10
+ from campaign_rpg_engine.actions.interact import interact as do_interact
11
+ from campaign_rpg_engine.actions.interact import interact_phases as do_interact_phases
12
+ from campaign_rpg_engine.actions.move import move as do_move
13
+ from campaign_rpg_engine.actions.speak import speak as do_speak
14
+
15
+ __all__ = ["do_emote", "do_interact", "do_interact_phases", "do_move", "do_speak"]
@@ -0,0 +1,24 @@
1
+ """Emote turn action — gesture at an entity or free-text target (V0.4.2)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from campaign_rpg_engine.action_outcome import ActionOutcome
6
+ from campaign_rpg_engine.agent import Agent
7
+ from campaign_rpg_engine.area import Area
8
+ from campaign_rpg_engine.emote_phrasing import (
9
+ emote_target_phrase_for_actor,
10
+ emote_target_phrase_neutral,
11
+ format_emote_line,
12
+ )
13
+
14
+
15
+ def emote(agent: Agent, area: Area, target: str, action_name: str) -> ActionOutcome:
16
+ """Perform a past-tense emote directed at *target*."""
17
+ verb = action_name.strip()
18
+ target_id = target.strip()
19
+ actor_phrase = emote_target_phrase_for_actor(area, agent, target_id)
20
+ neutral_phrase = emote_target_phrase_neutral(area, target_id)
21
+ return ActionOutcome(
22
+ result=f"You {verb} at {actor_phrase}.",
23
+ passive_result=format_emote_line(agent.name, verb, neutral_phrase),
24
+ )