3tears-conversations 0.14.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 (35) hide show
  1. 3tears_conversations-0.14.0/.gitignore +216 -0
  2. 3tears_conversations-0.14.0/LICENSE +21 -0
  3. 3tears_conversations-0.14.0/PKG-INFO +61 -0
  4. 3tears_conversations-0.14.0/README.md +39 -0
  5. 3tears_conversations-0.14.0/pyproject.toml +50 -0
  6. 3tears_conversations-0.14.0/src/threetears/conversations/__init__.py +71 -0
  7. 3tears_conversations-0.14.0/src/threetears/conversations/authorize.py +528 -0
  8. 3tears_conversations-0.14.0/src/threetears/conversations/buffer.py +367 -0
  9. 3tears_conversations-0.14.0/src/threetears/conversations/collection.py +676 -0
  10. 3tears_conversations-0.14.0/src/threetears/conversations/entity.py +535 -0
  11. 3tears_conversations-0.14.0/src/threetears/conversations/events.py +72 -0
  12. 3tears_conversations-0.14.0/src/threetears/conversations/folder_collection.py +186 -0
  13. 3tears_conversations-0.14.0/src/threetears/conversations/folder_entity.py +285 -0
  14. 3tears_conversations-0.14.0/src/threetears/conversations/merge.py +70 -0
  15. 3tears_conversations-0.14.0/src/threetears/conversations/migrations/__init__.py +143 -0
  16. 3tears_conversations-0.14.0/src/threetears/conversations/migrations/v001_create_conversations_table.py +60 -0
  17. 3tears_conversations-0.14.0/src/threetears/conversations/migrations/v002_add_message_count.py +56 -0
  18. 3tears_conversations-0.14.0/src/threetears/conversations/migrations/v003_add_name_column.py +59 -0
  19. 3tears_conversations-0.14.0/src/threetears/conversations/migrations/v004_datetime_to_datetimetz.py +153 -0
  20. 3tears_conversations-0.14.0/src/threetears/conversations/migrations/v005_conversation_search_vector.py +112 -0
  21. 3tears_conversations-0.14.0/src/threetears/conversations/migrations/v006_conversation_language_column.py +121 -0
  22. 3tears_conversations-0.14.0/src/threetears/conversations/migrations/v007_rename_id_to_conversation_id.py +120 -0
  23. 3tears_conversations-0.14.0/src/threetears/conversations/migrations/v008_create_folders_and_conversation_folder_id.py +126 -0
  24. 3tears_conversations-0.14.0/src/threetears/conversations/migrations/v009_folder_referential_integrity.py +108 -0
  25. 3tears_conversations-0.14.0/src/threetears/conversations/py.typed +0 -0
  26. 3tears_conversations-0.14.0/tests/conftest.py +16 -0
  27. 3tears_conversations-0.14.0/tests/test_merge.py +60 -0
  28. 3tears_conversations-0.14.0/tests/unit/test_authorize.py +537 -0
  29. 3tears_conversations-0.14.0/tests/unit/test_buffer.py +274 -0
  30. 3tears_conversations-0.14.0/tests/unit/test_collection.py +614 -0
  31. 3tears_conversations-0.14.0/tests/unit/test_entity.py +371 -0
  32. 3tears_conversations-0.14.0/tests/unit/test_events.py +28 -0
  33. 3tears_conversations-0.14.0/tests/unit/test_folder.py +655 -0
  34. 3tears_conversations-0.14.0/tests/unit/test_lifecycle_hooks.py +172 -0
  35. 3tears_conversations-0.14.0/tests/unit/test_migrations.py +603 -0
@@ -0,0 +1,216 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
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
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ # Claude Code local state
210
+ .claude/
211
+
212
+ # prawduct session evidence (local governance artifacts, never shipped)
213
+ .prawduct/
214
+
215
+ # macOS folder metadata
216
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mark Pace
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,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: 3tears-conversations
3
+ Version: 0.14.0
4
+ Summary: Conversation entity, three-tier collection, and per-agent schema migrations shared by memory and tool packages
5
+ Project-URL: Repository, https://github.com/pacepace/3tears
6
+ Author: pace
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Framework :: AsyncIO
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Topic :: Software Development :: Libraries
15
+ Classifier: Typing :: Typed
16
+ Requires-Python: >=3.14
17
+ Requires-Dist: 3tears
18
+ Requires-Dist: 3tears-agent-acl
19
+ Requires-Dist: 3tears-langgraph
20
+ Requires-Dist: 3tears-observe
21
+ Description-Content-Type: text/markdown
22
+
23
+ # 3tears-conversations
24
+
25
+ Canonical owner of the per-agent `conversations` table plus its entity and three-tier collection.
26
+
27
+ ## Purpose
28
+
29
+ Tracks one row per user-facing conversation an agent is engaged in: ownership scope (`agent_id`, `customer_id`, `user_id`), external reference (`channel_type`, `conversation_ref`), lifecycle (`status`, `summary`), timestamps (`date_created`, `date_updated`, `date_last_message`).
30
+
31
+ This table is owned here because multiple packages key off `conversation_id` (memory, agent-tools context items, workspace bindings) and no single consumer is the natural owner of the shape. Owning the table here lets each downstream package depend on `conversations` without pulling in memory's extraction pipeline.
32
+
33
+ ## Public API
34
+
35
+ Exports (see `src/threetears/conversations/__init__.py`):
36
+
37
+ - `Conversation` -- `BaseEntity` subclass for a single row.
38
+ - `ConversationsCollection` -- three-tier (`L1` SQLite / `L2` NATS KV / `L3` postgres) collection with the usual `get` / `save` / `subscript` semantics.
39
+ - `register(runner)` -- agent-scope migration entry point. Contributes the `conversations` table creation to a canonical `threetears.core.data.migrations.MigrationRunner`. No `depends_on` edges; this is the root of the agent-schema dependency graph, so memory / workspace / tools migrations that reference `conversations.id` sort after it.
40
+
41
+ ## Minimal usage
42
+
43
+ ```python
44
+ from threetears.conversations import Conversation, ConversationsCollection, register
45
+ from threetears.core.data.migrations import MigrationRunner
46
+
47
+ # 1. register the package's migrations on the runner
48
+ runner = MigrationRunner(store)
49
+ register(runner)
50
+ await store.run_migrations(runner)
51
+
52
+ # 2. use the collection like any other 3tears collection
53
+ collection = ConversationsCollection(registry=registry)
54
+ conv = await collection.get(conversation_id)
55
+ conv.summary = "follow-up on last week's analysis"
56
+ await conv.save()
57
+ ```
58
+
59
+ ## Reference
60
+
61
+ - Downstream consumers: `threetears.agent.memory`, `threetears.agent.tools` (context items), `threetears.agent.workspace` (bindings)
@@ -0,0 +1,39 @@
1
+ # 3tears-conversations
2
+
3
+ Canonical owner of the per-agent `conversations` table plus its entity and three-tier collection.
4
+
5
+ ## Purpose
6
+
7
+ Tracks one row per user-facing conversation an agent is engaged in: ownership scope (`agent_id`, `customer_id`, `user_id`), external reference (`channel_type`, `conversation_ref`), lifecycle (`status`, `summary`), timestamps (`date_created`, `date_updated`, `date_last_message`).
8
+
9
+ This table is owned here because multiple packages key off `conversation_id` (memory, agent-tools context items, workspace bindings) and no single consumer is the natural owner of the shape. Owning the table here lets each downstream package depend on `conversations` without pulling in memory's extraction pipeline.
10
+
11
+ ## Public API
12
+
13
+ Exports (see `src/threetears/conversations/__init__.py`):
14
+
15
+ - `Conversation` -- `BaseEntity` subclass for a single row.
16
+ - `ConversationsCollection` -- three-tier (`L1` SQLite / `L2` NATS KV / `L3` postgres) collection with the usual `get` / `save` / `subscript` semantics.
17
+ - `register(runner)` -- agent-scope migration entry point. Contributes the `conversations` table creation to a canonical `threetears.core.data.migrations.MigrationRunner`. No `depends_on` edges; this is the root of the agent-schema dependency graph, so memory / workspace / tools migrations that reference `conversations.id` sort after it.
18
+
19
+ ## Minimal usage
20
+
21
+ ```python
22
+ from threetears.conversations import Conversation, ConversationsCollection, register
23
+ from threetears.core.data.migrations import MigrationRunner
24
+
25
+ # 1. register the package's migrations on the runner
26
+ runner = MigrationRunner(store)
27
+ register(runner)
28
+ await store.run_migrations(runner)
29
+
30
+ # 2. use the collection like any other 3tears collection
31
+ collection = ConversationsCollection(registry=registry)
32
+ conv = await collection.get(conversation_id)
33
+ conv.summary = "follow-up on last week's analysis"
34
+ await conv.save()
35
+ ```
36
+
37
+ ## Reference
38
+
39
+ - Downstream consumers: `threetears.agent.memory`, `threetears.agent.tools` (context items), `threetears.agent.workspace` (bindings)
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "3tears-conversations"
7
+ version = "0.14.0"
8
+ description = "Conversation entity, three-tier collection, and per-agent schema migrations shared by memory and tool packages"
9
+ readme = "README.md"
10
+ requires-python = ">=3.14"
11
+ authors = [{name = "pace"}]
12
+ license = "MIT"
13
+ license-files = ["LICENSE"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Framework :: AsyncIO",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.14",
20
+ "Topic :: Software Development :: Libraries",
21
+ "Typing :: Typed",
22
+ ]
23
+ dependencies = [
24
+ "3tears",
25
+ "3tears-agent-acl",
26
+ "3tears-langgraph",
27
+ "3tears-observe",
28
+ ]
29
+
30
+ [project.urls]
31
+ Repository = "https://github.com/pacepace/3tears"
32
+
33
+ [tool.hatch.build.targets.wheel]
34
+ packages = ["src/threetears"]
35
+
36
+ [tool.uv.sources]
37
+ 3tears = { workspace = true }
38
+ 3tears-agent-acl = { workspace = true }
39
+ 3tears-langgraph = { workspace = true }
40
+ 3tears-observe = { workspace = true }
41
+
42
+ [tool.mypy]
43
+ strict = true
44
+ mypy_path = "src"
45
+ packages = ["threetears.conversations"]
46
+ explicit_package_bases = true
47
+ ignore_missing_imports = true
48
+
49
+ [tool.pytest.ini_options]
50
+ asyncio_mode = "auto"
@@ -0,0 +1,71 @@
1
+ """conversations package public surface.
2
+
3
+ owns the :class:`Conversation` entity, the
4
+ :class:`ConversationsCollection` three-tier collection, and the
5
+ agent-scope migration registering the ``conversations`` table. pulled
6
+ out of :mod:`threetears.agent.memory` because multiple packages --
7
+ memory, agent-tools context items, and upcoming workspace bindings --
8
+ key off ``conversation_id`` but none of them is the natural owner.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ # Version derived from pyproject.toml so the metadata is the single
14
+ # source of truth -- a future release that bumps pyproject without
15
+ # updating ``__init__.py`` can't drift the runtime ``__version__``.
16
+ # The except guard handles the rare case where the package isn't
17
+ # installed via importlib.metadata (e.g. running directly from a
18
+ # checked-out source tree without ``uv sync``); the fallback keeps
19
+ # imports working but reports ``unknown`` rather than crashing.
20
+ from importlib.metadata import PackageNotFoundError as _PackageNotFoundError
21
+ from importlib.metadata import version as _version
22
+
23
+ try:
24
+ __version__ = _version("3tears-conversations")
25
+ except _PackageNotFoundError: # pragma: no cover - dev fallback
26
+ __version__ = "unknown"
27
+
28
+ from threetears.conversations.authorize import (
29
+ ACTION_CONVERSATION_DELETE,
30
+ ACTION_CONVERSATION_READ,
31
+ ACTION_CONVERSATION_WRITE,
32
+ CONVERSATION_NAMESPACE_TYPE,
33
+ CONVERSATION_OWNER_GROUP_PREFIX,
34
+ CONVERSATION_OWNER_ROLE_NAME,
35
+ ConversationAccessDenied,
36
+ ConversationAuthorizerDependencies,
37
+ authorize_conversation_access,
38
+ conversation_namespace_name,
39
+ ensure_conversation_owner_assignment,
40
+ )
41
+ from threetears.conversations.buffer import ConversationWriteBuffer
42
+ from threetears.conversations.collection import ConversationsCollection
43
+ from threetears.conversations.entity import Conversation, ConversationStatus
44
+ from threetears.conversations.events import ConversationSummarizedEvent
45
+ from threetears.conversations.folder_collection import FolderCollection
46
+ from threetears.conversations.folder_entity import Folder
47
+ from threetears.conversations.merge import repoint_user
48
+ from threetears.conversations.migrations import register
49
+
50
+ __all__ = [
51
+ "ACTION_CONVERSATION_DELETE",
52
+ "ACTION_CONVERSATION_READ",
53
+ "ACTION_CONVERSATION_WRITE",
54
+ "CONVERSATION_NAMESPACE_TYPE",
55
+ "CONVERSATION_OWNER_GROUP_PREFIX",
56
+ "CONVERSATION_OWNER_ROLE_NAME",
57
+ "Conversation",
58
+ "ConversationAccessDenied",
59
+ "ConversationAuthorizerDependencies",
60
+ "ConversationStatus",
61
+ "ConversationSummarizedEvent",
62
+ "ConversationWriteBuffer",
63
+ "ConversationsCollection",
64
+ "Folder",
65
+ "FolderCollection",
66
+ "authorize_conversation_access",
67
+ "conversation_namespace_name",
68
+ "ensure_conversation_owner_assignment",
69
+ "register",
70
+ "repoint_user",
71
+ ]