camosur 0.1.0a1__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.
- camosur-0.1.0a1/LICENSE +202 -0
- camosur-0.1.0a1/NOTICE +4 -0
- camosur-0.1.0a1/PKG-INFO +139 -0
- camosur-0.1.0a1/README.md +113 -0
- camosur-0.1.0a1/brain/__init__.py +5 -0
- camosur-0.1.0a1/brain/activities.py +120 -0
- camosur-0.1.0a1/brain/activity.py +81 -0
- camosur-0.1.0a1/brain/app.py +50 -0
- camosur-0.1.0a1/brain/bedrock_proxy.py +49 -0
- camosur-0.1.0a1/brain/budget.py +207 -0
- camosur-0.1.0a1/brain/chat/__init__.py +5 -0
- camosur-0.1.0a1/brain/chat/activity.py +171 -0
- camosur-0.1.0a1/brain/chat/attendance.py +107 -0
- camosur-0.1.0a1/brain/chat/catchup.py +67 -0
- camosur-0.1.0a1/brain/chat/chattiness.py +77 -0
- camosur-0.1.0a1/brain/chat/commands/__init__.py +19 -0
- camosur-0.1.0a1/brain/chat/commands/chattiness.py +35 -0
- camosur-0.1.0a1/brain/chat/commands/directive.py +54 -0
- camosur-0.1.0a1/brain/chat/commands/flag.py +95 -0
- camosur-0.1.0a1/brain/chat/commands/presence.py +132 -0
- camosur-0.1.0a1/brain/chat/commands/schedule.py +194 -0
- camosur-0.1.0a1/brain/chat/farewell.py +66 -0
- camosur-0.1.0a1/brain/chat/log.py +29 -0
- camosur-0.1.0a1/brain/chat/marks.py +32 -0
- camosur-0.1.0a1/brain/chat/opener.py +124 -0
- camosur-0.1.0a1/brain/chat/policy.py +168 -0
- camosur-0.1.0a1/brain/chat/presence.py +155 -0
- camosur-0.1.0a1/brain/chat/reply.py +170 -0
- camosur-0.1.0a1/brain/chat/rules.py +111 -0
- camosur-0.1.0a1/brain/chat/schedule.py +251 -0
- camosur-0.1.0a1/brain/chat/store.py +37 -0
- camosur-0.1.0a1/brain/chat/titles.py +302 -0
- camosur-0.1.0a1/brain/chat/upkeep.py +38 -0
- camosur-0.1.0a1/brain/commands/__init__.py +130 -0
- camosur-0.1.0a1/brain/commands/budget.py +25 -0
- camosur-0.1.0a1/brain/commands/channel.py +93 -0
- camosur-0.1.0a1/brain/commands/help.py +68 -0
- camosur-0.1.0a1/brain/commands/mask.py +59 -0
- camosur-0.1.0a1/brain/commands/parse.py +193 -0
- camosur-0.1.0a1/brain/commands/person.py +168 -0
- camosur-0.1.0a1/brain/commands/records.py +70 -0
- camosur-0.1.0a1/brain/commands/registry.py +215 -0
- camosur-0.1.0a1/brain/commands/status.py +20 -0
- camosur-0.1.0a1/brain/config.py +583 -0
- camosur-0.1.0a1/brain/context.py +368 -0
- camosur-0.1.0a1/brain/detect.py +145 -0
- camosur-0.1.0a1/brain/evals/__init__.py +0 -0
- camosur-0.1.0a1/brain/evals/__main__.py +151 -0
- camosur-0.1.0a1/brain/evals/cases.py +329 -0
- camosur-0.1.0a1/brain/evals/checks.py +182 -0
- camosur-0.1.0a1/brain/evals/models.py +150 -0
- camosur-0.1.0a1/brain/evals/report.py +176 -0
- camosur-0.1.0a1/brain/evals/run.py +309 -0
- camosur-0.1.0a1/brain/feed.py +74 -0
- camosur-0.1.0a1/brain/fetch.py +287 -0
- camosur-0.1.0a1/brain/game/__init__.py +1 -0
- camosur-0.1.0a1/brain/game/activity.py +278 -0
- camosur-0.1.0a1/brain/game/characters.py +137 -0
- camosur-0.1.0a1/brain/game/commands/__init__.py +64 -0
- camosur-0.1.0a1/brain/game/commands/campaign.py +174 -0
- camosur-0.1.0a1/brain/game/commands/expedition.py +247 -0
- camosur-0.1.0a1/brain/game/commands/journal.py +45 -0
- camosur-0.1.0a1/brain/game/commands/map.py +33 -0
- camosur-0.1.0a1/brain/game/commands/pc.py +79 -0
- camosur-0.1.0a1/brain/game/commands/play.py +70 -0
- camosur-0.1.0a1/brain/game/commands/town.py +121 -0
- camosur-0.1.0a1/brain/game/context.py +183 -0
- camosur-0.1.0a1/brain/game/dice.py +55 -0
- camosur-0.1.0a1/brain/game/expedition.py +144 -0
- camosur-0.1.0a1/brain/game/gm.py +482 -0
- camosur-0.1.0a1/brain/game/guide.py +61 -0
- camosur-0.1.0a1/brain/game/hexmap.py +126 -0
- camosur-0.1.0a1/brain/game/journal.py +37 -0
- camosur-0.1.0a1/brain/game/maps.py +94 -0
- camosur-0.1.0a1/brain/game/mapsvg.py +573 -0
- camosur-0.1.0a1/brain/game/rules.py +619 -0
- camosur-0.1.0a1/brain/game/srd/classes.json +253 -0
- camosur-0.1.0a1/brain/game/srd/equipment.json +400 -0
- camosur-0.1.0a1/brain/game/srd/monsters.json +536 -0
- camosur-0.1.0a1/brain/game/srd/races.json +26 -0
- camosur-0.1.0a1/brain/game/srd/spells.json +400 -0
- camosur-0.1.0a1/brain/game/srd/xp.json +4 -0
- camosur-0.1.0a1/brain/game/srd.py +428 -0
- camosur-0.1.0a1/brain/game/store.py +285 -0
- camosur-0.1.0a1/brain/game/table.py +93 -0
- camosur-0.1.0a1/brain/game/tiles.py +120 -0
- camosur-0.1.0a1/brain/game/tools.py +669 -0
- camosur-0.1.0a1/brain/game/town.py +130 -0
- camosur-0.1.0a1/brain/guard.py +139 -0
- camosur-0.1.0a1/brain/help/__init__.py +5 -0
- camosur-0.1.0a1/brain/help/activity.py +129 -0
- camosur-0.1.0a1/brain/identity.py +201 -0
- camosur-0.1.0a1/brain/limits.py +42 -0
- camosur-0.1.0a1/brain/lines.py +289 -0
- camosur-0.1.0a1/brain/links.py +43 -0
- camosur-0.1.0a1/brain/llm.py +408 -0
- camosur-0.1.0a1/brain/memory.py +100 -0
- camosur-0.1.0a1/brain/outbox.py +171 -0
- camosur-0.1.0a1/brain/persona.example.toml +60 -0
- camosur-0.1.0a1/brain/pricing.py +77 -0
- camosur-0.1.0a1/brain/reflect/__init__.py +5 -0
- camosur-0.1.0a1/brain/reflect/job.py +259 -0
- camosur-0.1.0a1/brain/reflect/model.py +107 -0
- camosur-0.1.0a1/brain/reflect/prompts.py +79 -0
- camosur-0.1.0a1/brain/reflect/revise.py +184 -0
- camosur-0.1.0a1/brain/reflect/sincerity.py +63 -0
- camosur-0.1.0a1/brain/reflect/stats.py +128 -0
- camosur-0.1.0a1/brain/reflect/write.py +202 -0
- camosur-0.1.0a1/brain/rhythm.py +86 -0
- camosur-0.1.0a1/brain/slap/__init__.py +5 -0
- camosur-0.1.0a1/brain/slap/activity.py +235 -0
- camosur-0.1.0a1/brain/slap/generate.py +148 -0
- camosur-0.1.0a1/brain/slap/parse.py +111 -0
- camosur-0.1.0a1/brain/statuspage.py +194 -0
- camosur-0.1.0a1/brain/store/__init__.py +15 -0
- camosur-0.1.0a1/brain/store/base.py +25 -0
- camosur-0.1.0a1/brain/store/channels.py +127 -0
- camosur-0.1.0a1/brain/store/common.py +11 -0
- camosur-0.1.0a1/brain/store/flags.py +58 -0
- camosur-0.1.0a1/brain/store/outbox.py +37 -0
- camosur-0.1.0a1/brain/store/people.py +119 -0
- camosur-0.1.0a1/brain/store/spend.py +37 -0
- camosur-0.1.0a1/brain/store/state.py +104 -0
- camosur-0.1.0a1/brain/timers.py +20 -0
- camosur-0.1.0a1/brain/transport.py +117 -0
- camosur-0.1.0a1/brain/turn/__init__.py +1 -0
- camosur-0.1.0a1/brain/turn/marks.py +10 -0
- camosur-0.1.0a1/brain/turn/owner.py +155 -0
- camosur-0.1.0a1/brain/turn/people.py +157 -0
- camosur-0.1.0a1/brain/turn/queue.py +42 -0
- camosur-0.1.0a1/brain/turn/reply.py +234 -0
- camosur-0.1.0a1/brain/turn/serve.py +133 -0
- camosur-0.1.0a1/brain/turn/session.py +136 -0
- camosur-0.1.0a1/brain/turn/signoff.py +23 -0
- camosur-0.1.0a1/brain/turn/transcript.py +38 -0
- camosur-0.1.0a1/brain/worker.py +118 -0
- camosur-0.1.0a1/camosur/__init__.py +0 -0
- camosur-0.1.0a1/camosur/irc/__init__.py +37 -0
- camosur-0.1.0a1/camosur/irc/client.py +569 -0
- camosur-0.1.0a1/camosur/irc/ctcp.py +37 -0
- camosur-0.1.0a1/camosur/irc/message.py +170 -0
- camosur-0.1.0a1/camosur/irc/numerics.py +48 -0
- camosur-0.1.0a1/camosur/irc/ratelimit.py +28 -0
- camosur-0.1.0a1/camosur/irc/tls.py +55 -0
- camosur-0.1.0a1/camosur.egg-info/PKG-INFO +139 -0
- camosur-0.1.0a1/camosur.egg-info/SOURCES.txt +168 -0
- camosur-0.1.0a1/camosur.egg-info/dependency_links.txt +1 -0
- camosur-0.1.0a1/camosur.egg-info/entry_points.txt +7 -0
- camosur-0.1.0a1/camosur.egg-info/requires.txt +12 -0
- camosur-0.1.0a1/camosur.egg-info/top_level.txt +5 -0
- camosur-0.1.0a1/pyproject.toml +55 -0
- camosur-0.1.0a1/relay/__init__.py +0 -0
- camosur-0.1.0a1/relay/botlist.py +48 -0
- camosur-0.1.0a1/relay/config.py +198 -0
- camosur-0.1.0a1/relay/ident.py +135 -0
- camosur-0.1.0a1/relay/session.py +194 -0
- camosur-0.1.0a1/relay/store.py +74 -0
- camosur-0.1.0a1/relay/supervisor.py +202 -0
- camosur-0.1.0a1/runner/__init__.py +0 -0
- camosur-0.1.0a1/runner/cloudwatch.py +173 -0
- camosur-0.1.0a1/runner/config.py +516 -0
- camosur-0.1.0a1/runner/main.py +319 -0
- camosur-0.1.0a1/runner/maps.py +88 -0
- camosur-0.1.0a1/setup.cfg +4 -0
- camosur-0.1.0a1/shared/__init__.py +0 -0
- camosur-0.1.0a1/shared/events.py +40 -0
- camosur-0.1.0a1/shared/keys.py +118 -0
- camosur-0.1.0a1/shared/migrate.py +238 -0
- camosur-0.1.0a1/shared/sqlite.py +189 -0
- camosur-0.1.0a1/shared/version.py +13 -0
camosur-0.1.0a1/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
camosur-0.1.0a1/NOTICE
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
camosur
|
|
2
|
+
Copyright 2026 The camosur authors
|
|
3
|
+
|
|
4
|
+
This work includes material taken from the System Reference Document 5.1 ("SRD 5.1") by Wizards of the Coast LLC and available at https://dnd.wizards.com/resources/systems-reference-document. The SRD 5.1 is licensed under the Creative Commons Attribution 4.0 International License available at https://creativecommons.org/licenses/by/4.0/legalcode.
|
camosur-0.1.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: camosur
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: An IRC chat persona and game master backed by a language model
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://camosur.com
|
|
7
|
+
Project-URL: Repository, https://github.com/kjiwa/camosur
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Topic :: Communications :: Chat :: Internet Relay Chat
|
|
13
|
+
Requires-Python: >=3.13
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
License-File: NOTICE
|
|
17
|
+
Provides-Extra: bedrock
|
|
18
|
+
Requires-Dist: pydantic-ai-slim[bedrock]==2.75.0; extra == "bedrock"
|
|
19
|
+
Provides-Extra: anthropic
|
|
20
|
+
Requires-Dist: pydantic-ai-slim[anthropic]==2.75.0; extra == "anthropic"
|
|
21
|
+
Provides-Extra: openai
|
|
22
|
+
Requires-Dist: pydantic-ai-slim[openai]==2.75.0; extra == "openai"
|
|
23
|
+
Provides-Extra: all
|
|
24
|
+
Requires-Dist: pydantic-ai-slim[anthropic,bedrock,openai]==2.75.0; extra == "all"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
<p align="center"><img src="logo.svg" width="96" alt=""></p>
|
|
28
|
+
|
|
29
|
+
# camosur
|
|
30
|
+
|
|
31
|
+
An IRC chat persona and West Marches D&D game master backed by a language model.
|
|
32
|
+
|
|
33
|
+
`camosur` connects to one or more IRC networks, keeps a shared WAL-mode SQLite database between its IRC relay and LLM brain, participates in channel banter on a schedule with presence windows and spend caps, reflects nightly on conversations, and runs West Marches D&D 5e (SRD 5.1) expeditions via `!dnd`.
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
`camosur` requires Python 3.13 or later and declares no base dependencies — install the provider extra you need (`openai`, `anthropic`, `bedrock`, or `all`).
|
|
38
|
+
|
|
39
|
+
### Local with Ollama (free)
|
|
40
|
+
|
|
41
|
+
Ollama's OpenAI-compatible API uses the `openai` extra:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
pip install 'camosur[openai]'
|
|
45
|
+
ollama pull qwen2.5:7b
|
|
46
|
+
camosur run ircs://irc.example.org/#channel
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`camosur run` with an IRC URL seeds the channel and an always-on schedule in `camosur.db`, turns disclosure on (`AI bot - https://camosur.com`), auto-detects Ollama on `http://127.0.0.1:11434`, and prints a one-time `/msg <nick> claim <code>` instruction to stderr so you can claim ownership on IRC.
|
|
50
|
+
|
|
51
|
+
### Cloud providers
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
# Anthropic (uses ANTHROPIC_API_KEY)
|
|
55
|
+
pip install 'camosur[anthropic]'
|
|
56
|
+
camosur run ircs://irc.example.org/#channel
|
|
57
|
+
|
|
58
|
+
# OpenAI (uses OPENAI_API_KEY)
|
|
59
|
+
pip install 'camosur[openai]'
|
|
60
|
+
camosur run ircs://irc.example.org/#channel
|
|
61
|
+
|
|
62
|
+
# Amazon Bedrock (uses ambient AWS credentials)
|
|
63
|
+
pip install 'camosur[bedrock]'
|
|
64
|
+
camosur run ircs://irc.example.org/#channel
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Pass `--model PROVIDER:MODEL` (e.g. `--model anthropic:claude-haiku-4-5`) to override auto-detection, or `--nick NICK` to override the persona's default nick.
|
|
68
|
+
|
|
69
|
+
### Configuration file
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
camosur init
|
|
73
|
+
# Edit camosur.toml and persona.toml
|
|
74
|
+
camosur run
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`camosur init` writes a starter `camosur.toml` and `persona.toml` (copied from `brain/persona.example.toml`). Without a URL, `camosur run` reads `camosur.toml`, or falls back to `relay.json` and `brain.json`. Pass `--only relay` or `--only brain` to run the two sides in separate processes sharing `--db`.
|
|
78
|
+
|
|
79
|
+
## Models and evals
|
|
80
|
+
|
|
81
|
+
`camosur` routes each job to a named model slot (`banter`, `guard`, `reflection`, and `game`). Small models handle the non-GM routes well; the West Marches GM route is more demanding.
|
|
82
|
+
|
|
83
|
+
Results from the fictional public eval suite (`brain/evals/results/2026-12-03.md`, 3 runs per case, projected at 100 calls/day):
|
|
84
|
+
|
|
85
|
+
| Route | Model | Limit cases (strict) | Limit cases (2/3 runs) | Contract | Est. USD/month |
|
|
86
|
+
|---|---|---|---|---|---:|
|
|
87
|
+
| `guard` | `us.amazon.nova-lite-v1:0` | 10/10 | 10/10 | 30/30 | 0.07 |
|
|
88
|
+
| `banter` | `global.anthropic.claude-haiku-4-5-20251001-v1:0` | 9/10 | 10/10 | 36/36 | 2.34 |
|
|
89
|
+
| `reflection` | `us.amazon.nova-pro-v1:0` | 6/6 | 6/6 | 18/18 | 3.12 |
|
|
90
|
+
| `game` | `global.anthropic.claude-haiku-4-5-20251001-v1:0` | 4/8 | 4/8 | 24/24 | 17.58 |
|
|
91
|
+
|
|
92
|
+
Note: `game` is currently below gate on Haiku 4.5 (4/8 cases); evaluate a stronger model before relying on it for West Marches sessions.
|
|
93
|
+
|
|
94
|
+
Run the eval suite against any candidate model:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
python -m brain.evals --route banter --models <model-id> --guard-model <guard-id>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Deploying on AWS
|
|
101
|
+
|
|
102
|
+
For a self-hosted AWS deployment (single Spot EC2 instance over IPv6, Litestream SQLite replication to S3, Bedrock Converse proxy Lambda, status page, and optional D&D hex map publishing), use the [terraform-aws-camosur](https://github.com/kjiwa/terraform-aws-camosur) Terraform module.
|
|
103
|
+
|
|
104
|
+
## Design and activities
|
|
105
|
+
|
|
106
|
+
See [docs/architecture.md](docs/architecture.md) for process topology, message dispatch, and deployment diagrams.
|
|
107
|
+
|
|
108
|
+
- **Chat** (`brain/chat/`): Presence windows, measured channel rhythm, burst holding, thread-aware addressing, catch-up remarks, conversation openers, link title fetching, outbound safety guard (`KEEP`/`DROP`), daily and monthly spend caps, and nightly reflection (`brain/reflect/`). Turn rules evaluate in order (`away`, `hard`, `summon`, `answer`, `quiet`, `held`, `queued`, `other`, `engaged`, `unprompted`), and periodic ticks evaluate `backlog`, `catchup`, and `opener`.
|
|
109
|
+
- **West Marches** (`brain/game/`): SRD 5.1 rules core (Fighter, Rogue, Cleric, Wizard to level 5; four races; spells to 3rd level; ~20 monsters), seeded hex map with SVG/HTML rendering, expeditions, and shared journal. Players interact in-channel via `!dnd`.
|
|
110
|
+
- **Slap** (`brain/slap/`): `!slap <nick>` and `!slap <nick> with <item>` with configurable trout chance and cooldown.
|
|
111
|
+
- **Help** (`brain/help/`): `!help` lists public activity commands via NOTICE.
|
|
112
|
+
- **Activities plugin API** (`brain/activity.py`): Additional activities register via the `camosur.activities` entry point group.
|
|
113
|
+
|
|
114
|
+
### Owner commands
|
|
115
|
+
|
|
116
|
+
Private messages from configured owner masks or IRCv3 accounts are commands answered via NOTICE with no model call; non-owner DMs are ignored (except the one-time `claim <code>` bootstrap when unowned). Send `/msg <nick> help` to list `Core`, `Chat`, and `Activities` commands (`status`, `budget`, `schedule`, `presence`, `channel`, `person`, `mask`, `directive`, `campaign`, `flag`).
|
|
117
|
+
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
pip install -r requirements-dev.txt
|
|
122
|
+
pytest
|
|
123
|
+
pre-commit run --all-files
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Layout:
|
|
127
|
+
|
|
128
|
+
- `camosur/irc/`: Standard-library-only IRC client (IRCv3 capabilities, SASL PLAIN, TLS certificate pinning, CTCP, rate limiting).
|
|
129
|
+
- `relay/`: Multi-network IRC bridge, `!botlist`/`!rollcall`, ident server, and SQLite event/outbox loop.
|
|
130
|
+
- `brain/`: Activity dispatch, chat presence/rhythm/guard/budget, nightly reflection, West Marches GM, owner commands, and evals.
|
|
131
|
+
- `shared/`: Shared SQLite store, key encoding, event helpers, and package version lookup.
|
|
132
|
+
- `runner/`: CLI (`camosur`), `camosur.toml`/URL config, CloudWatch/status/map wiring.
|
|
133
|
+
- `scripts/`: Utility scripts (`models.py`, `transcript.py`, `corpus.py`, `migrate_state.py`, `denylist.sh`).
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
Licensed under the [Apache License 2.0](LICENSE). See [NOTICE](NOTICE) for third-party attributions.
|
|
138
|
+
|
|
139
|
+
This work includes material taken from the System Reference Document 5.1 ("SRD 5.1") by Wizards of the Coast LLC and available at https://dnd.wizards.com/resources/systems-reference-document. The SRD 5.1 is licensed under the Creative Commons Attribution 4.0 International License available at https://creativecommons.org/licenses/by/4.0/legalcode.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<p align="center"><img src="logo.svg" width="96" alt=""></p>
|
|
2
|
+
|
|
3
|
+
# camosur
|
|
4
|
+
|
|
5
|
+
An IRC chat persona and West Marches D&D game master backed by a language model.
|
|
6
|
+
|
|
7
|
+
`camosur` connects to one or more IRC networks, keeps a shared WAL-mode SQLite database between its IRC relay and LLM brain, participates in channel banter on a schedule with presence windows and spend caps, reflects nightly on conversations, and runs West Marches D&D 5e (SRD 5.1) expeditions via `!dnd`.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
`camosur` requires Python 3.13 or later and declares no base dependencies — install the provider extra you need (`openai`, `anthropic`, `bedrock`, or `all`).
|
|
12
|
+
|
|
13
|
+
### Local with Ollama (free)
|
|
14
|
+
|
|
15
|
+
Ollama's OpenAI-compatible API uses the `openai` extra:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pip install 'camosur[openai]'
|
|
19
|
+
ollama pull qwen2.5:7b
|
|
20
|
+
camosur run ircs://irc.example.org/#channel
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`camosur run` with an IRC URL seeds the channel and an always-on schedule in `camosur.db`, turns disclosure on (`AI bot - https://camosur.com`), auto-detects Ollama on `http://127.0.0.1:11434`, and prints a one-time `/msg <nick> claim <code>` instruction to stderr so you can claim ownership on IRC.
|
|
24
|
+
|
|
25
|
+
### Cloud providers
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
# Anthropic (uses ANTHROPIC_API_KEY)
|
|
29
|
+
pip install 'camosur[anthropic]'
|
|
30
|
+
camosur run ircs://irc.example.org/#channel
|
|
31
|
+
|
|
32
|
+
# OpenAI (uses OPENAI_API_KEY)
|
|
33
|
+
pip install 'camosur[openai]'
|
|
34
|
+
camosur run ircs://irc.example.org/#channel
|
|
35
|
+
|
|
36
|
+
# Amazon Bedrock (uses ambient AWS credentials)
|
|
37
|
+
pip install 'camosur[bedrock]'
|
|
38
|
+
camosur run ircs://irc.example.org/#channel
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Pass `--model PROVIDER:MODEL` (e.g. `--model anthropic:claude-haiku-4-5`) to override auto-detection, or `--nick NICK` to override the persona's default nick.
|
|
42
|
+
|
|
43
|
+
### Configuration file
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
camosur init
|
|
47
|
+
# Edit camosur.toml and persona.toml
|
|
48
|
+
camosur run
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`camosur init` writes a starter `camosur.toml` and `persona.toml` (copied from `brain/persona.example.toml`). Without a URL, `camosur run` reads `camosur.toml`, or falls back to `relay.json` and `brain.json`. Pass `--only relay` or `--only brain` to run the two sides in separate processes sharing `--db`.
|
|
52
|
+
|
|
53
|
+
## Models and evals
|
|
54
|
+
|
|
55
|
+
`camosur` routes each job to a named model slot (`banter`, `guard`, `reflection`, and `game`). Small models handle the non-GM routes well; the West Marches GM route is more demanding.
|
|
56
|
+
|
|
57
|
+
Results from the fictional public eval suite (`brain/evals/results/2026-12-03.md`, 3 runs per case, projected at 100 calls/day):
|
|
58
|
+
|
|
59
|
+
| Route | Model | Limit cases (strict) | Limit cases (2/3 runs) | Contract | Est. USD/month |
|
|
60
|
+
|---|---|---|---|---|---:|
|
|
61
|
+
| `guard` | `us.amazon.nova-lite-v1:0` | 10/10 | 10/10 | 30/30 | 0.07 |
|
|
62
|
+
| `banter` | `global.anthropic.claude-haiku-4-5-20251001-v1:0` | 9/10 | 10/10 | 36/36 | 2.34 |
|
|
63
|
+
| `reflection` | `us.amazon.nova-pro-v1:0` | 6/6 | 6/6 | 18/18 | 3.12 |
|
|
64
|
+
| `game` | `global.anthropic.claude-haiku-4-5-20251001-v1:0` | 4/8 | 4/8 | 24/24 | 17.58 |
|
|
65
|
+
|
|
66
|
+
Note: `game` is currently below gate on Haiku 4.5 (4/8 cases); evaluate a stronger model before relying on it for West Marches sessions.
|
|
67
|
+
|
|
68
|
+
Run the eval suite against any candidate model:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
python -m brain.evals --route banter --models <model-id> --guard-model <guard-id>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Deploying on AWS
|
|
75
|
+
|
|
76
|
+
For a self-hosted AWS deployment (single Spot EC2 instance over IPv6, Litestream SQLite replication to S3, Bedrock Converse proxy Lambda, status page, and optional D&D hex map publishing), use the [terraform-aws-camosur](https://github.com/kjiwa/terraform-aws-camosur) Terraform module.
|
|
77
|
+
|
|
78
|
+
## Design and activities
|
|
79
|
+
|
|
80
|
+
See [docs/architecture.md](docs/architecture.md) for process topology, message dispatch, and deployment diagrams.
|
|
81
|
+
|
|
82
|
+
- **Chat** (`brain/chat/`): Presence windows, measured channel rhythm, burst holding, thread-aware addressing, catch-up remarks, conversation openers, link title fetching, outbound safety guard (`KEEP`/`DROP`), daily and monthly spend caps, and nightly reflection (`brain/reflect/`). Turn rules evaluate in order (`away`, `hard`, `summon`, `answer`, `quiet`, `held`, `queued`, `other`, `engaged`, `unprompted`), and periodic ticks evaluate `backlog`, `catchup`, and `opener`.
|
|
83
|
+
- **West Marches** (`brain/game/`): SRD 5.1 rules core (Fighter, Rogue, Cleric, Wizard to level 5; four races; spells to 3rd level; ~20 monsters), seeded hex map with SVG/HTML rendering, expeditions, and shared journal. Players interact in-channel via `!dnd`.
|
|
84
|
+
- **Slap** (`brain/slap/`): `!slap <nick>` and `!slap <nick> with <item>` with configurable trout chance and cooldown.
|
|
85
|
+
- **Help** (`brain/help/`): `!help` lists public activity commands via NOTICE.
|
|
86
|
+
- **Activities plugin API** (`brain/activity.py`): Additional activities register via the `camosur.activities` entry point group.
|
|
87
|
+
|
|
88
|
+
### Owner commands
|
|
89
|
+
|
|
90
|
+
Private messages from configured owner masks or IRCv3 accounts are commands answered via NOTICE with no model call; non-owner DMs are ignored (except the one-time `claim <code>` bootstrap when unowned). Send `/msg <nick> help` to list `Core`, `Chat`, and `Activities` commands (`status`, `budget`, `schedule`, `presence`, `channel`, `person`, `mask`, `directive`, `campaign`, `flag`).
|
|
91
|
+
|
|
92
|
+
## Development
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
pip install -r requirements-dev.txt
|
|
96
|
+
pytest
|
|
97
|
+
pre-commit run --all-files
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Layout:
|
|
101
|
+
|
|
102
|
+
- `camosur/irc/`: Standard-library-only IRC client (IRCv3 capabilities, SASL PLAIN, TLS certificate pinning, CTCP, rate limiting).
|
|
103
|
+
- `relay/`: Multi-network IRC bridge, `!botlist`/`!rollcall`, ident server, and SQLite event/outbox loop.
|
|
104
|
+
- `brain/`: Activity dispatch, chat presence/rhythm/guard/budget, nightly reflection, West Marches GM, owner commands, and evals.
|
|
105
|
+
- `shared/`: Shared SQLite store, key encoding, event helpers, and package version lookup.
|
|
106
|
+
- `runner/`: CLI (`camosur`), `camosur.toml`/URL config, CloudWatch/status/map wiring.
|
|
107
|
+
- `scripts/`: Utility scripts (`models.py`, `transcript.py`, `corpus.py`, `migrate_state.py`, `denylist.sh`).
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
Licensed under the [Apache License 2.0](LICENSE). See [NOTICE](NOTICE) for third-party attributions.
|
|
112
|
+
|
|
113
|
+
This work includes material taken from the System Reference Document 5.1 ("SRD 5.1") by Wizards of the Coast LLC and available at https://dnd.wizards.com/resources/systems-reference-document. The SRD 5.1 is licensed under the Creative Commons Attribution 4.0 International License available at https://creativecommons.org/licenses/by/4.0/legalcode.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""The activities in the order they are offered a channel's lines."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Iterable
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
from importlib.metadata import entry_points
|
|
6
|
+
|
|
7
|
+
from brain import LOG, identity
|
|
8
|
+
from brain.activity import Activity
|
|
9
|
+
from brain.chat import CHAT
|
|
10
|
+
from brain.turn.session import Heard, Session
|
|
11
|
+
|
|
12
|
+
ENTRY_POINT_GROUP = "camosur.activities"
|
|
13
|
+
DEFAULT_ENTRY_POINTS: tuple[tuple[str, str], ...] = (
|
|
14
|
+
("help", "brain.help.activity:HELP"),
|
|
15
|
+
("game", "brain.game.activity:GAME"),
|
|
16
|
+
("slap", "brain.slap.activity:SLAP"),
|
|
17
|
+
)
|
|
18
|
+
FALLBACK = CHAT
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _import_target(spec: str) -> Activity:
|
|
22
|
+
module_name, _, attr = spec.partition(":")
|
|
23
|
+
module = import_module(module_name)
|
|
24
|
+
return getattr(module, attr)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _load_entry_points() -> list[tuple[str, Activity]]:
|
|
28
|
+
loaded_eps: list[tuple[str, Activity]] = []
|
|
29
|
+
for ep in entry_points(group=ENTRY_POINT_GROUP):
|
|
30
|
+
try:
|
|
31
|
+
loaded_eps.append((ep.name, ep.load()))
|
|
32
|
+
except Exception: # noqa: BLE001 - a broken plugin must not break startup
|
|
33
|
+
LOG.exception("activity entry point %s failed to load", ep.name)
|
|
34
|
+
return loaded_eps
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def load_activities(
|
|
38
|
+
builtins: tuple[Activity, ...] | None = None,
|
|
39
|
+
fallback: Activity = CHAT,
|
|
40
|
+
) -> tuple[Activity, ...]:
|
|
41
|
+
"""Loads built-in or entry-point activities, with `fallback` always last."""
|
|
42
|
+
found: list[Activity] = []
|
|
43
|
+
eps = _load_entry_points()
|
|
44
|
+
if builtins is not None:
|
|
45
|
+
found.extend(builtins)
|
|
46
|
+
for _, loaded in eps:
|
|
47
|
+
if loaded is not fallback and not any(x is loaded for x in found):
|
|
48
|
+
found.append(loaded)
|
|
49
|
+
else:
|
|
50
|
+
by_name: dict[str, Activity] = {}
|
|
51
|
+
for name, loaded in eps:
|
|
52
|
+
by_name.setdefault(name, loaded)
|
|
53
|
+
for name, target in DEFAULT_ENTRY_POINTS:
|
|
54
|
+
loaded = by_name.get(name) or _import_target(target)
|
|
55
|
+
if loaded is not fallback and not any(x is loaded for x in found):
|
|
56
|
+
found.append(loaded)
|
|
57
|
+
for _, loaded in eps:
|
|
58
|
+
if loaded is not fallback and not any(x is loaded for x in found):
|
|
59
|
+
found.append(loaded)
|
|
60
|
+
found.append(fallback)
|
|
61
|
+
return tuple(found)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
ACTIVITIES: tuple[Activity, ...] = load_activities()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def public_commands(items: Iterable[Activity] | None = None) -> tuple[str, ...]:
|
|
68
|
+
"""Unique non-hidden command triggers declared by `items` in declaration order."""
|
|
69
|
+
triggers = [
|
|
70
|
+
trigger
|
|
71
|
+
for activity in (ACTIVITIES if items is None else items)
|
|
72
|
+
for spec in getattr(activity, "commands", ())
|
|
73
|
+
if not spec.hidden
|
|
74
|
+
for trigger in spec.triggers
|
|
75
|
+
]
|
|
76
|
+
return tuple(dict.fromkeys(triggers))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def is_activity_command(text: str, items: Iterable[Activity] | None = None) -> bool:
|
|
80
|
+
"""True when `text` opens with a declared `CommandSpec` trigger token."""
|
|
81
|
+
stripped = text.lstrip()
|
|
82
|
+
if not stripped:
|
|
83
|
+
return False
|
|
84
|
+
head = stripped.split(None, 1)[0].lower()
|
|
85
|
+
for activity in ACTIVITIES if items is None else items:
|
|
86
|
+
for spec in getattr(activity, "commands", ()):
|
|
87
|
+
for trigger in spec.triggers:
|
|
88
|
+
if head == trigger.lower():
|
|
89
|
+
return True
|
|
90
|
+
return False
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def unclaimed_events(
|
|
94
|
+
session: Session, events: list[dict], items: Iterable[Activity] | None = None
|
|
95
|
+
) -> list[dict]:
|
|
96
|
+
"""Events not claimed by any non-chat activity."""
|
|
97
|
+
remaining: list[Heard] = []
|
|
98
|
+
for event in events:
|
|
99
|
+
source = event.get("source", "")
|
|
100
|
+
who = (
|
|
101
|
+
identity.resolve(
|
|
102
|
+
source,
|
|
103
|
+
session.owner,
|
|
104
|
+
session.masks,
|
|
105
|
+
session.seens,
|
|
106
|
+
session.now,
|
|
107
|
+
session.network,
|
|
108
|
+
account=event.get("account"),
|
|
109
|
+
)
|
|
110
|
+
if "!" in source
|
|
111
|
+
else identity.Identity("", identity.NONE)
|
|
112
|
+
)
|
|
113
|
+
remaining.append(Heard(event, who))
|
|
114
|
+
for activity in ACTIVITIES if items is None else items:
|
|
115
|
+
if activity is CHAT:
|
|
116
|
+
continue
|
|
117
|
+
mine = activity.claim(session, remaining)
|
|
118
|
+
taken = {id(h) for h in mine}
|
|
119
|
+
remaining = [h for h in remaining if id(h) not in taken]
|
|
120
|
+
return [h.event for h in remaining]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""The seam between the serving loop and what camosur does in a channel."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import TYPE_CHECKING, Protocol
|
|
5
|
+
|
|
6
|
+
from brain import outbox
|
|
7
|
+
from brain.store import Store
|
|
8
|
+
from brain.turn.session import Heard, Session
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from brain.commands.registry import CommandRegistry
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True)
|
|
15
|
+
class Output:
|
|
16
|
+
"""How an activity's replies are produced and checked: model route, the most lines
|
|
17
|
+
sent, whether narration lines go out, the guard's rules for the reply and the pace its
|
|
18
|
+
lines are typed at."""
|
|
19
|
+
|
|
20
|
+
route: str
|
|
21
|
+
max_lines: int
|
|
22
|
+
narration: bool
|
|
23
|
+
cue: str
|
|
24
|
+
pace: outbox.Pace
|
|
25
|
+
activity: str = ""
|
|
26
|
+
retry: bool = False
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass(frozen=True)
|
|
30
|
+
class CommandSpec:
|
|
31
|
+
"""Public or hidden chat trigger prefixes claimed by an activity."""
|
|
32
|
+
|
|
33
|
+
triggers: tuple[str, ...]
|
|
34
|
+
hidden: bool = False
|
|
35
|
+
summary: str = ""
|
|
36
|
+
usage: str = ""
|
|
37
|
+
registry: "CommandRegistry | None" = None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def format_spec_help(spec: CommandSpec) -> list[str]:
|
|
41
|
+
"""Single-line usage and summary for a channel command spec."""
|
|
42
|
+
label = spec.usage or spec.triggers[0]
|
|
43
|
+
return [f"{label}: {spec.summary}"] if spec.summary else [label]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class Activity(Protocol):
|
|
47
|
+
commands: tuple[CommandSpec, ...]
|
|
48
|
+
|
|
49
|
+
def claim(self, session: Session, heard: list[Heard]) -> list[Heard]:
|
|
50
|
+
"""The lines this activity takes from the unclaimed `heard`."""
|
|
51
|
+
...
|
|
52
|
+
|
|
53
|
+
def turn(self, session: Session, heard: list[Heard]) -> None:
|
|
54
|
+
"""Acts on the claimed lines and logs its own turn line."""
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
def holds(self, session: Session) -> bool:
|
|
58
|
+
"""True while this activity keeps camosur in the channel."""
|
|
59
|
+
...
|
|
60
|
+
|
|
61
|
+
def tick(self, session: Session) -> None:
|
|
62
|
+
"""Periodic work, run under the channel's lock."""
|
|
63
|
+
...
|
|
64
|
+
|
|
65
|
+
def forget(self, store: Store, handle: str) -> None:
|
|
66
|
+
"""Deletes what this activity stores about the person."""
|
|
67
|
+
...
|
|
68
|
+
|
|
69
|
+
def channel_note(self, session: Session) -> str:
|
|
70
|
+
"""Optional context note for chat in this channel when this activity is idle."""
|
|
71
|
+
...
|
|
72
|
+
|
|
73
|
+
# Optional hooks an activity may also define (checked via getattr):
|
|
74
|
+
# - register_owner_commands(self, registry: CommandRegistry) -> None
|
|
75
|
+
# - pre_tick(self, app: App, pks: list[str]) -> None
|
|
76
|
+
# - status_lines(self, ctx: Context) -> list[str]
|
|
77
|
+
# - presence_section(self, store: Store, config: Config, now: float, local: datetime) -> dict
|
|
78
|
+
# - channel_summary(self, item: dict, config: Config | None = None) -> str
|
|
79
|
+
# - channel_value(self, item: dict, config: Config | None = None) -> str
|
|
80
|
+
# - status_summary(self, item: dict) -> str
|
|
81
|
+
# - publish_maps(self, app: App, state: dict[str, str]) -> None
|