chatom 0.2.2__tar.gz → 0.2.3__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.
- {chatom-0.2.2 → chatom-0.2.3}/PKG-INFO +18 -9
- {chatom-0.2.2 → chatom-0.2.3}/README.md +12 -7
- {chatom-0.2.2 → chatom-0.2.3}/chatom/__init__.py +13 -1
- {chatom-0.2.2 → chatom-0.2.3}/chatom/agent/toolset.py +22 -2
- {chatom-0.2.2 → chatom-0.2.3}/chatom/backend/backend.py +1 -1
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/__init__.py +6 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/capabilities.py +57 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/message.py +1 -1
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/testing.py +4 -4
- {chatom-0.2.2 → chatom-0.2.3}/chatom/csp/__init__.py +2 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/csp/interactions.py +8 -11
- {chatom-0.2.2 → chatom-0.2.3}/chatom/csp/nodes.py +115 -167
- chatom-0.2.3/chatom/csp/runner.py +104 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/discord/backend.py +79 -9
- {chatom-0.2.2 → chatom-0.2.3}/chatom/enums.py +13 -10
- chatom-0.2.3/chatom/examples/_backends.py +296 -0
- chatom-0.2.3/chatom/examples/basic_connection.py +59 -0
- chatom-0.2.3/chatom/examples/cross_platform_bot.py +141 -0
- chatom-0.2.3/chatom/examples/direct_messages.py +84 -0
- chatom-0.2.3/chatom/examples/formatted_messages.py +137 -0
- chatom-0.2.3/chatom/examples/listen_for_messages.py +111 -0
- chatom-0.2.3/chatom/examples/mentions_and_reactions.py +109 -0
- chatom-0.2.3/chatom/examples/message_history.py +86 -0
- chatom-0.2.3/chatom/examples/send_message.py +65 -0
- chatom-0.2.3/chatom/examples/threads_and_replies.py +106 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/examples/unified_frontend.py +1 -1
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/message.py +3 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/text.py +6 -5
- chatom-0.2.3/chatom/irc/__init__.py +23 -0
- chatom-0.2.3/chatom/irc/backend.py +514 -0
- chatom-0.2.3/chatom/irc/channel.py +28 -0
- chatom-0.2.3/chatom/irc/config.py +40 -0
- chatom-0.2.3/chatom/irc/mention.py +17 -0
- chatom-0.2.3/chatom/irc/message.py +24 -0
- chatom-0.2.3/chatom/irc/presence.py +11 -0
- chatom-0.2.3/chatom/irc/testing.py +99 -0
- chatom-0.2.3/chatom/irc/user.py +38 -0
- chatom-0.2.3/chatom/matrix/__init__.py +26 -0
- chatom-0.2.3/chatom/matrix/backend.py +598 -0
- chatom-0.2.3/chatom/matrix/channel.py +25 -0
- chatom-0.2.3/chatom/matrix/config.py +49 -0
- chatom-0.2.3/chatom/matrix/e2ee.py +505 -0
- chatom-0.2.3/chatom/matrix/mention.py +30 -0
- chatom-0.2.3/chatom/matrix/message.py +27 -0
- chatom-0.2.3/chatom/matrix/presence.py +36 -0
- chatom-0.2.3/chatom/matrix/testing.py +302 -0
- chatom-0.2.3/chatom/matrix/user.py +27 -0
- chatom-0.2.3/chatom/mcp/config/gateway/irc.yaml +9 -0
- chatom-0.2.3/chatom/mcp/config/gateway/matrix.yaml +10 -0
- chatom-0.2.3/chatom/mcp/config/gateway/zulip.yaml +9 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/symphony/config.py +1 -1
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_agent.py +48 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_csp.py +22 -2
- chatom-0.2.3/chatom/tests/test_csp_runner.py +285 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_discord_channel_conversion.py +18 -1
- chatom-0.2.3/chatom/tests/test_discord_threads.py +118 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_enums.py +4 -3
- chatom-0.2.3/chatom/tests/test_example_backends.py +60 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_format.py +7 -0
- chatom-0.2.3/chatom/tests/test_irc_backend.py +952 -0
- chatom-0.2.3/chatom/tests/test_matrix_backend.py +1316 -0
- chatom-0.2.3/chatom/tests/test_matrix_e2ee.py +371 -0
- chatom-0.2.3/chatom/tests/test_mcp_gateway_presets.py +48 -0
- chatom-0.2.3/chatom/tests/test_zulip_backend.py +1242 -0
- chatom-0.2.3/chatom/zulip/__init__.py +30 -0
- chatom-0.2.3/chatom/zulip/backend.py +539 -0
- chatom-0.2.3/chatom/zulip/channel.py +30 -0
- chatom-0.2.3/chatom/zulip/config.py +40 -0
- chatom-0.2.3/chatom/zulip/mention.py +18 -0
- chatom-0.2.3/chatom/zulip/message.py +23 -0
- chatom-0.2.3/chatom/zulip/presence.py +36 -0
- chatom-0.2.3/chatom/zulip/testing.py +249 -0
- chatom-0.2.3/chatom/zulip/user.py +19 -0
- {chatom-0.2.2 → chatom-0.2.3}/pyproject.toml +15 -4
- chatom-0.2.2/chatom/examples/basic_connection.py +0 -161
- chatom-0.2.2/chatom/examples/cross_platform_bot.py +0 -243
- chatom-0.2.2/chatom/examples/direct_messages.py +0 -230
- chatom-0.2.2/chatom/examples/formatted_messages.py +0 -283
- chatom-0.2.2/chatom/examples/listen_for_messages.py +0 -224
- chatom-0.2.2/chatom/examples/mentions_and_reactions.py +0 -293
- chatom-0.2.2/chatom/examples/message_history.py +0 -245
- chatom-0.2.2/chatom/examples/send_message.py +0 -209
- chatom-0.2.2/chatom/examples/threads_and_replies.py +0 -275
- {chatom-0.2.2 → chatom-0.2.3}/.gitignore +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/LICENSE +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/agent/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/agent/context.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/agent/files.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/backend/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/backend/backend_config.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/backend/backend_registry.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/attachment.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/authorization.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/base.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/channel.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/connection.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/conversion.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/embed.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/interaction.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/mention.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/organization.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/presence.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/reaction.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/thread.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/base/user.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/bridge/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/bridge/identity.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/bridge/relay.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/csp/adapter.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/discord/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/discord/channel.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/discord/config.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/discord/guild.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/discord/mention.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/discord/message.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/discord/presence.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/discord/testing.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/discord/user.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/examples/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/attachment.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/components.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/embed.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/parse.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/spec/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/spec/symphony.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/table.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/telegram.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/format/variant.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/handlers.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/cli.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/config/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/config/config.yaml +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/config/gateway/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/config/gateway/discord.yaml +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/config/gateway/slack.yaml +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/config/gateway/symphony.yaml +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/config/gateway/symphony_dev.yaml +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/config/gateway/telegram.yaml +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/mcp/server.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/slack/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/slack/backend.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/slack/channel.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/slack/config.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/slack/mention.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/slack/message.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/slack/presence.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/slack/testing.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/slack/user.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/symphony/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/symphony/backend.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/symphony/channel.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/symphony/mention.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/symphony/message.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/symphony/presence.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/symphony/testing.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/symphony/user.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/telegram/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/telegram/backend.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/telegram/channel.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/telegram/config.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/telegram/mention.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/telegram/message.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/telegram/presence.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/telegram/testing.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/telegram/user.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/combined_e2e.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/conversion/test_message_conversion.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/conversion/test_message_conversion_cross.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/conversion/test_message_conversion_discord.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/conversion/test_message_conversion_slack.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/conversion/test_message_conversion_symphony.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/conversion/test_symphony_messageml_compliance.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/conversion/test_telegram_html.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/integration/__init__.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/integration/test_discord_integration.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/integration/test_slack_integration.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/integration/test_symphony_integration.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/integration/test_telegram_integration.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_access_policy.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_all.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_attachment_files.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_backend.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_backend_registry.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_backends.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_base_models.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_bot_features.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_bridge.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_config.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_connection.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_conversion.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_incoming_attachments.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_interactions.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_mcp.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_mention.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_mock_backends.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_symphony_fetch_messages.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_testing.py +0 -0
- {chatom-0.2.2 → chatom-0.2.3}/chatom/tests/test_threads.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: chatom
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Minimum viable chat components
|
|
5
5
|
Project-URL: Repository, https://github.com/1kbgz/chatom
|
|
6
6
|
Project-URL: Homepage, https://github.com/1kbgz/chatom
|
|
7
7
|
Author-email: the chatom authors <dev@1kbgz.com>
|
|
8
8
|
License: Apache-2.0
|
|
9
9
|
License-File: LICENSE
|
|
10
|
-
Keywords: agent,chat,chatbot,discord,llm,mcp,messenger,model-context-protocol,slack,symphony,telegram
|
|
10
|
+
Keywords: agent,chat,chatbot,discord,irc,llm,matrix,mcp,messenger,model-context-protocol,slack,symphony,telegram,zulip
|
|
11
11
|
Classifier: Development Status :: 3 - Alpha
|
|
12
12
|
Classifier: Programming Language :: Python
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -37,7 +37,10 @@ Requires-Dist: discord-py; extra == 'develop'
|
|
|
37
37
|
Requires-Dist: fastmcp>=2; extra == 'develop'
|
|
38
38
|
Requires-Dist: hatchling; extra == 'develop'
|
|
39
39
|
Requires-Dist: hydra-core>=1.3; extra == 'develop'
|
|
40
|
+
Requires-Dist: matrix-nio>=0.25; extra == 'develop'
|
|
41
|
+
Requires-Dist: matrix-sdk-python>=0.18; extra == 'develop'
|
|
40
42
|
Requires-Dist: mdformat; extra == 'develop'
|
|
43
|
+
Requires-Dist: mdformat-myst; extra == 'develop'
|
|
41
44
|
Requires-Dist: mdformat-tables>=1; extra == 'develop'
|
|
42
45
|
Requires-Dist: openpyxl<4,>=3.1; extra == 'develop'
|
|
43
46
|
Requires-Dist: pydantic-ai>=0.4; extra == 'develop'
|
|
@@ -57,26 +60,27 @@ Requires-Dist: ty; extra == 'develop'
|
|
|
57
60
|
Requires-Dist: uv; extra == 'develop'
|
|
58
61
|
Requires-Dist: whatsapp-python; extra == 'develop'
|
|
59
62
|
Requires-Dist: wheel; extra == 'develop'
|
|
63
|
+
Requires-Dist: zulip; extra == 'develop'
|
|
60
64
|
Provides-Extra: mcp
|
|
61
65
|
Requires-Dist: fastmcp>=2; extra == 'mcp'
|
|
62
66
|
Requires-Dist: hydra-core>=1.3; extra == 'mcp'
|
|
63
67
|
Description-Content-Type: text/markdown
|
|
64
68
|
|
|
65
69
|
<p>
|
|
66
|
-
<img src="https://github.com/1kbgz/chatom/raw/main/docs/img/logo-light.png?raw=true#gh-light-mode-only" alt="chatom" width="150">
|
|
67
|
-
<img src="https://github.com/1kbgz/chatom/raw/main/docs/img/logo-dark.png?raw=true#gh-dark-mode-only" alt="chatom" width="150">
|
|
70
|
+
<img class="logo-light" src="https://github.com/1kbgz/chatom/raw/main/docs/img/logo-light.png?raw=true#gh-light-mode-only" alt="chatom" width="150">
|
|
71
|
+
<img class="logo-dark" src="https://github.com/1kbgz/chatom/raw/main/docs/img/logo-dark.png?raw=true#gh-dark-mode-only" alt="chatom" width="150">
|
|
68
72
|
</p>
|
|
69
73
|
|
|
70
74
|
# Chatom
|
|
71
75
|
|
|
72
|
-
A unified Python frontend for Discord, Slack, Symphony, Telegram, and
|
|
76
|
+
A unified Python frontend for Discord, IRC, Matrix, Slack, Symphony, Telegram, and Zulip.
|
|
73
77
|
|
|
74
78
|
[](https://github.com/1kbgz/chatom/actions/workflows/build.yaml)
|
|
75
79
|
[](https://codecov.io/gh/1kbgz/chatom)
|
|
76
80
|
[](https://github.com/1kbgz/chatom)
|
|
77
81
|
[](https://pypi.python.org/pypi/chatom)
|
|
78
82
|
|
|
79
|
-
Chatom lets application code use one set of users, channels, messages, formatting nodes, interactions, and backend operations. Platform adapters translate that frontend to Discord, Slack, Symphony, or
|
|
83
|
+
Chatom lets application code use one set of users, channels, messages, formatting nodes, interactions, and backend operations. Platform adapters translate that frontend to Discord, IRC, Matrix, Slack, Symphony, Telegram, or Zulip at the edge. The same models also feed cross-platform bridges, pydantic-ai tools, MCP servers, and CSP graphs.
|
|
80
84
|
|
|
81
85
|
## Install
|
|
82
86
|
|
|
@@ -89,12 +93,12 @@ pip install chatom
|
|
|
89
93
|
Install the SDKs for the backends you use:
|
|
90
94
|
|
|
91
95
|
```bash
|
|
92
|
-
pip install slack-sdk discord.py symphony-bdk-python python-telegram-bot
|
|
96
|
+
pip install slack-sdk discord.py matrix-nio symphony-bdk-python python-telegram-bot zulip
|
|
93
97
|
```
|
|
94
98
|
|
|
95
99
|
Optional integrations are available with `chatom[agent]` and `chatom[mcp]`.
|
|
96
100
|
|
|
97
|
-
## One message,
|
|
101
|
+
## One message, every backend
|
|
98
102
|
|
|
99
103
|
```python
|
|
100
104
|
from chatom import MessageBuilder
|
|
@@ -116,8 +120,13 @@ slack_content = message.render_for("slack")
|
|
|
116
120
|
discord_content = message.render_for("discord")
|
|
117
121
|
symphony_content = message.render_for("symphony")
|
|
118
122
|
telegram_content = message.render_for("telegram")
|
|
123
|
+
matrix_content = message.render_for("matrix")
|
|
124
|
+
zulip_content = message.render_for("zulip")
|
|
125
|
+
irc_content = message.render_for("irc")
|
|
119
126
|
```
|
|
120
127
|
|
|
128
|
+
Each backend receives its own dialect: mrkdwn for Slack, Markdown for Discord and Zulip, HTML for Symphony and Matrix, Telegram's HTML subset, and plain text for IRC.
|
|
129
|
+
|
|
121
130
|
Message construction stays unchanged. Only rendering and backend configuration know which platform receives it.
|
|
122
131
|
|
|
123
132
|
Connected backends share the same lifecycle and operation shape:
|
|
@@ -140,7 +149,7 @@ finally:
|
|
|
140
149
|
- Model promotion and demotion between common and backend-specific types
|
|
141
150
|
- Identity mapping and message forwarding between platforms
|
|
142
151
|
- Agent, MCP, and CSP integrations built on the same backend contract
|
|
143
|
-
- In-memory
|
|
152
|
+
- In-memory backends for all supported platforms
|
|
144
153
|
|
|
145
154
|
## Documentation
|
|
146
155
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
<img src="https://github.com/1kbgz/chatom/raw/main/docs/img/logo-light.png?raw=true#gh-light-mode-only" alt="chatom" width="150">
|
|
3
|
-
<img src="https://github.com/1kbgz/chatom/raw/main/docs/img/logo-dark.png?raw=true#gh-dark-mode-only" alt="chatom" width="150">
|
|
2
|
+
<img class="logo-light" src="https://github.com/1kbgz/chatom/raw/main/docs/img/logo-light.png?raw=true#gh-light-mode-only" alt="chatom" width="150">
|
|
3
|
+
<img class="logo-dark" src="https://github.com/1kbgz/chatom/raw/main/docs/img/logo-dark.png?raw=true#gh-dark-mode-only" alt="chatom" width="150">
|
|
4
4
|
</p>
|
|
5
5
|
|
|
6
6
|
# Chatom
|
|
7
7
|
|
|
8
|
-
A unified Python frontend for Discord, Slack, Symphony, Telegram, and
|
|
8
|
+
A unified Python frontend for Discord, IRC, Matrix, Slack, Symphony, Telegram, and Zulip.
|
|
9
9
|
|
|
10
10
|
[](https://github.com/1kbgz/chatom/actions/workflows/build.yaml)
|
|
11
11
|
[](https://codecov.io/gh/1kbgz/chatom)
|
|
12
12
|
[](https://github.com/1kbgz/chatom)
|
|
13
13
|
[](https://pypi.python.org/pypi/chatom)
|
|
14
14
|
|
|
15
|
-
Chatom lets application code use one set of users, channels, messages, formatting nodes, interactions, and backend operations. Platform adapters translate that frontend to Discord, Slack, Symphony, or
|
|
15
|
+
Chatom lets application code use one set of users, channels, messages, formatting nodes, interactions, and backend operations. Platform adapters translate that frontend to Discord, IRC, Matrix, Slack, Symphony, Telegram, or Zulip at the edge. The same models also feed cross-platform bridges, pydantic-ai tools, MCP servers, and CSP graphs.
|
|
16
16
|
|
|
17
17
|
## Install
|
|
18
18
|
|
|
@@ -25,12 +25,12 @@ pip install chatom
|
|
|
25
25
|
Install the SDKs for the backends you use:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
pip install slack-sdk discord.py symphony-bdk-python python-telegram-bot
|
|
28
|
+
pip install slack-sdk discord.py matrix-nio symphony-bdk-python python-telegram-bot zulip
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
Optional integrations are available with `chatom[agent]` and `chatom[mcp]`.
|
|
32
32
|
|
|
33
|
-
## One message,
|
|
33
|
+
## One message, every backend
|
|
34
34
|
|
|
35
35
|
```python
|
|
36
36
|
from chatom import MessageBuilder
|
|
@@ -52,8 +52,13 @@ slack_content = message.render_for("slack")
|
|
|
52
52
|
discord_content = message.render_for("discord")
|
|
53
53
|
symphony_content = message.render_for("symphony")
|
|
54
54
|
telegram_content = message.render_for("telegram")
|
|
55
|
+
matrix_content = message.render_for("matrix")
|
|
56
|
+
zulip_content = message.render_for("zulip")
|
|
57
|
+
irc_content = message.render_for("irc")
|
|
55
58
|
```
|
|
56
59
|
|
|
60
|
+
Each backend receives its own dialect: mrkdwn for Slack, Markdown for Discord and Zulip, HTML for Symphony and Matrix, Telegram's HTML subset, and plain text for IRC.
|
|
61
|
+
|
|
57
62
|
Message construction stays unchanged. Only rendering and backend configuration know which platform receives it.
|
|
58
63
|
|
|
59
64
|
Connected backends share the same lifecycle and operation shape:
|
|
@@ -76,7 +81,7 @@ finally:
|
|
|
76
81
|
- Model promotion and demotion between common and backend-specific types
|
|
77
82
|
- Identity mapping and message forwarding between platforms
|
|
78
83
|
- Agent, MCP, and CSP integrations built on the same backend contract
|
|
79
|
-
- In-memory
|
|
84
|
+
- In-memory backends for all supported platforms
|
|
80
85
|
|
|
81
86
|
## Documentation
|
|
82
87
|
|
|
@@ -31,9 +31,12 @@ from .backend import (
|
|
|
31
31
|
)
|
|
32
32
|
from .base import (
|
|
33
33
|
DISCORD_CAPABILITIES,
|
|
34
|
+
IRC_CAPABILITIES,
|
|
35
|
+
MATRIX_CAPABILITIES,
|
|
34
36
|
SLACK_CAPABILITIES,
|
|
35
37
|
SYMPHONY_CAPABILITIES,
|
|
36
38
|
TELEGRAM_CAPABILITIES,
|
|
39
|
+
ZULIP_CAPABILITIES,
|
|
37
40
|
# Presence
|
|
38
41
|
Activity,
|
|
39
42
|
ActivityType,
|
|
@@ -104,9 +107,12 @@ from .enums import (
|
|
|
104
107
|
ALL_BACKENDS,
|
|
105
108
|
BACKEND,
|
|
106
109
|
DISCORD,
|
|
110
|
+
IRC,
|
|
111
|
+
MATRIX,
|
|
107
112
|
SLACK,
|
|
108
113
|
SYMPHONY,
|
|
109
114
|
TELEGRAM,
|
|
115
|
+
ZULIP,
|
|
110
116
|
)
|
|
111
117
|
from .format import (
|
|
112
118
|
BACKEND_FORMAT_MAP,
|
|
@@ -166,7 +172,7 @@ from .format import (
|
|
|
166
172
|
)
|
|
167
173
|
from .handlers import InteractionHandler, InteractionRegistry
|
|
168
174
|
|
|
169
|
-
__version__ = "0.2.
|
|
175
|
+
__version__ = "0.2.3"
|
|
170
176
|
|
|
171
177
|
__all__ = (
|
|
172
178
|
"ALL_BACKENDS",
|
|
@@ -178,7 +184,11 @@ __all__ = (
|
|
|
178
184
|
"DISCORD_MARKDOWN",
|
|
179
185
|
"FORMAT",
|
|
180
186
|
"HTML",
|
|
187
|
+
"IRC",
|
|
188
|
+
"IRC_CAPABILITIES",
|
|
181
189
|
"MARKDOWN",
|
|
190
|
+
"MATRIX",
|
|
191
|
+
"MATRIX_CAPABILITIES",
|
|
182
192
|
"PLAINTEXT",
|
|
183
193
|
"SLACK",
|
|
184
194
|
"SLACK_CAPABILITIES",
|
|
@@ -189,6 +199,8 @@ __all__ = (
|
|
|
189
199
|
"TELEGRAM",
|
|
190
200
|
"TELEGRAM_CAPABILITIES",
|
|
191
201
|
"TELEGRAM_HTML",
|
|
202
|
+
"ZULIP",
|
|
203
|
+
"ZULIP_CAPABILITIES",
|
|
192
204
|
# Presence
|
|
193
205
|
"Activity",
|
|
194
206
|
"ActivityType",
|
|
@@ -14,7 +14,7 @@ from pydantic_ai.tools import ToolDefinition
|
|
|
14
14
|
from pydantic_ai.toolsets.abstract import AbstractToolset, ToolsetTool
|
|
15
15
|
|
|
16
16
|
from chatom.backend import AttachmentDownloadLimitError, BackendBase
|
|
17
|
-
from chatom.base import Channel, ChannelType, User
|
|
17
|
+
from chatom.base import Channel, ChannelType, Message, User
|
|
18
18
|
from chatom.base.capabilities import Capability
|
|
19
19
|
|
|
20
20
|
logger = logging.getLogger(__name__)
|
|
@@ -477,6 +477,11 @@ class BackendToolset(AbstractToolset[Any]):
|
|
|
477
477
|
(``send_message``, ``edit_message``, ``add_reaction``) are omitted
|
|
478
478
|
when *read_only* is ``True``.
|
|
479
479
|
|
|
480
|
+
The optional ``on_sent(original, sent)`` callback observes successful text
|
|
481
|
+
sends and file/image uploads. ``sent`` contains the platform's message ID;
|
|
482
|
+
``original`` preserves the requested channel, content, and filename metadata.
|
|
483
|
+
Callback errors are logged without failing or repeating the successful send.
|
|
484
|
+
|
|
480
485
|
Example::
|
|
481
486
|
|
|
482
487
|
from chatom.agent import BackendToolset
|
|
@@ -498,6 +503,7 @@ class BackendToolset(AbstractToolset[Any]):
|
|
|
498
503
|
max_tool_calls: int = 0,
|
|
499
504
|
per_tool_limits: dict[str, int] | None = None,
|
|
500
505
|
image_generator: Callable[[str], Awaitable[bytes]] | None = None,
|
|
506
|
+
on_sent: Callable[[Message, Message], None] | None = None,
|
|
501
507
|
) -> None:
|
|
502
508
|
self._backend = backend
|
|
503
509
|
self._read_only = read_only
|
|
@@ -505,6 +511,7 @@ class BackendToolset(AbstractToolset[Any]):
|
|
|
505
511
|
self._policy = access_policy or AccessPolicy()
|
|
506
512
|
self._disabled_tools = disabled_tools or set()
|
|
507
513
|
self._image_generator = image_generator
|
|
514
|
+
self._on_sent = on_sent
|
|
508
515
|
# Per-run tool call budget. 0 disables the total cap; per-tool limits
|
|
509
516
|
# may still apply. A single BackendToolset instance is expected to back
|
|
510
517
|
# exactly one agent run, so these counters scope naturally to a run.
|
|
@@ -521,6 +528,14 @@ class BackendToolset(AbstractToolset[Any]):
|
|
|
521
528
|
def id(self) -> str | None:
|
|
522
529
|
return f"chatom-{self._backend.name}" if self._backend.name else "chatom"
|
|
523
530
|
|
|
531
|
+
def _notify_sent(self, sent: Message, channel: Channel, content: str = "", filename: str = "") -> None:
|
|
532
|
+
if self._on_sent is not None:
|
|
533
|
+
original = Message(channel=channel, content=content, metadata={"filename": filename})
|
|
534
|
+
try:
|
|
535
|
+
self._on_sent(original, sent)
|
|
536
|
+
except Exception:
|
|
537
|
+
logger.exception("Sent-message observer failed")
|
|
538
|
+
|
|
524
539
|
def tool_definitions(self) -> dict[str, ToolDefinition]:
|
|
525
540
|
"""Return the tools available for this backend and policy."""
|
|
526
541
|
definitions: dict[str, ToolDefinition] = {}
|
|
@@ -901,10 +916,12 @@ class BackendToolset(AbstractToolset[Any]):
|
|
|
901
916
|
channel = self._channel(args)
|
|
902
917
|
channel = await self._resolve_channel_full(channel)
|
|
903
918
|
await self._check_channel_access(channel)
|
|
904
|
-
|
|
919
|
+
sent = await self._backend.send_message(
|
|
905
920
|
channel=channel,
|
|
906
921
|
content=args["content"],
|
|
907
922
|
)
|
|
923
|
+
self._notify_sent(sent, channel, args["content"])
|
|
924
|
+
return sent
|
|
908
925
|
|
|
909
926
|
async def _call_edit_message(self, args: dict[str, Any]) -> Any:
|
|
910
927
|
channel = self._channel(args)
|
|
@@ -1084,6 +1101,7 @@ class BackendToolset(AbstractToolset[Any]):
|
|
|
1084
1101
|
)
|
|
1085
1102
|
except ValueError as exc:
|
|
1086
1103
|
return {"error": "invalid_file", "message": str(exc)}
|
|
1104
|
+
self._notify_sent(sent, channel, args.get("content", ""), args["filename"])
|
|
1087
1105
|
return {"ok": True, "message_id": getattr(sent, "id", "") or ""}
|
|
1088
1106
|
|
|
1089
1107
|
async def _call_create_file(self, args: dict[str, Any]) -> Any:
|
|
@@ -1110,6 +1128,7 @@ class BackendToolset(AbstractToolset[Any]):
|
|
|
1110
1128
|
except (RuntimeError, OSError) as exc:
|
|
1111
1129
|
logger.warning("File creation/upload failed: %s", type(exc).__name__)
|
|
1112
1130
|
return {"error": "file_failed", "message": f"File creation or upload failed ({type(exc).__name__})."}
|
|
1131
|
+
self._notify_sent(sent, channel, args["content"], args["filename"])
|
|
1113
1132
|
return {"ok": True, "message_id": sent.id, "filename": args["filename"], "content_type": media_type, "size": len(data)}
|
|
1114
1133
|
|
|
1115
1134
|
async def _call_read_file(self, args: dict[str, Any]) -> Any:
|
|
@@ -1153,4 +1172,5 @@ class BackendToolset(AbstractToolset[Any]):
|
|
|
1153
1172
|
"error": "generation_failed",
|
|
1154
1173
|
"message": str(exc) if isinstance(exc, ValueError) else f"Image generation or upload failed ({type(exc).__name__}).",
|
|
1155
1174
|
}
|
|
1175
|
+
self._notify_sent(sent, channel, args["content"], args["filename"])
|
|
1156
1176
|
return {"ok": True, "message_id": sent.id, "filename": args["filename"], "content_type": "image/png", "size": len(data)}
|
|
@@ -238,7 +238,7 @@ class BackendBase(BaseModel):
|
|
|
238
238
|
default_factory=ChannelRegistry,
|
|
239
239
|
description="Registry of cached channels.",
|
|
240
240
|
)
|
|
241
|
-
config: Any
|
|
241
|
+
config: Any = Field(
|
|
242
242
|
default=None,
|
|
243
243
|
description="Backend-specific configuration. Subclasses override with their config type.",
|
|
244
244
|
)
|
|
@@ -16,9 +16,12 @@ from .authorization import (
|
|
|
16
16
|
from .base import BaseModel, Field, Identifiable
|
|
17
17
|
from .capabilities import (
|
|
18
18
|
DISCORD_CAPABILITIES,
|
|
19
|
+
IRC_CAPABILITIES,
|
|
20
|
+
MATRIX_CAPABILITIES,
|
|
19
21
|
SLACK_CAPABILITIES,
|
|
20
22
|
SYMPHONY_CAPABILITIES,
|
|
21
23
|
TELEGRAM_CAPABILITIES,
|
|
24
|
+
ZULIP_CAPABILITIES,
|
|
22
25
|
BackendCapabilities,
|
|
23
26
|
Capability,
|
|
24
27
|
)
|
|
@@ -74,9 +77,12 @@ Channel.model_rebuild()
|
|
|
74
77
|
|
|
75
78
|
__all__ = (
|
|
76
79
|
"DISCORD_CAPABILITIES",
|
|
80
|
+
"IRC_CAPABILITIES",
|
|
81
|
+
"MATRIX_CAPABILITIES",
|
|
77
82
|
"SLACK_CAPABILITIES",
|
|
78
83
|
"SYMPHONY_CAPABILITIES",
|
|
79
84
|
"TELEGRAM_CAPABILITIES",
|
|
85
|
+
"ZULIP_CAPABILITIES",
|
|
80
86
|
# Presence
|
|
81
87
|
"Activity",
|
|
82
88
|
"ActivityType",
|
|
@@ -9,9 +9,12 @@ from .base import BaseModel, Field
|
|
|
9
9
|
|
|
10
10
|
__all__ = (
|
|
11
11
|
"DISCORD_CAPABILITIES",
|
|
12
|
+
"IRC_CAPABILITIES",
|
|
13
|
+
"MATRIX_CAPABILITIES",
|
|
12
14
|
"SLACK_CAPABILITIES",
|
|
13
15
|
"SYMPHONY_CAPABILITIES",
|
|
14
16
|
"TELEGRAM_CAPABILITIES",
|
|
17
|
+
"ZULIP_CAPABILITIES",
|
|
15
18
|
"BackendCapabilities",
|
|
16
19
|
"Capability",
|
|
17
20
|
)
|
|
@@ -320,3 +323,57 @@ TELEGRAM_CAPABILITIES = BackendCapabilities(
|
|
|
320
323
|
max_attachment_size=50 * 1024 * 1024, # 50 MB
|
|
321
324
|
max_attachments=10,
|
|
322
325
|
)
|
|
326
|
+
|
|
327
|
+
IRC_CAPABILITIES = BackendCapabilities(
|
|
328
|
+
capabilities=frozenset(
|
|
329
|
+
{
|
|
330
|
+
Capability.PLAINTEXT,
|
|
331
|
+
Capability.USER_MENTIONS,
|
|
332
|
+
Capability.CHANNEL_MENTIONS,
|
|
333
|
+
Capability.PRESENCE,
|
|
334
|
+
}
|
|
335
|
+
),
|
|
336
|
+
max_message_length=400,
|
|
337
|
+
max_attachment_size=0,
|
|
338
|
+
max_attachments=0,
|
|
339
|
+
max_embeds=0,
|
|
340
|
+
max_reactions=0,
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
MATRIX_CAPABILITIES = BackendCapabilities(
|
|
344
|
+
capabilities=frozenset(
|
|
345
|
+
{
|
|
346
|
+
Capability.PLAINTEXT,
|
|
347
|
+
Capability.HTML,
|
|
348
|
+
Capability.CODE_BLOCKS,
|
|
349
|
+
Capability.THREADS,
|
|
350
|
+
Capability.REPLIES,
|
|
351
|
+
Capability.USER_MENTIONS,
|
|
352
|
+
Capability.CHANNEL_MENTIONS,
|
|
353
|
+
Capability.EDITING,
|
|
354
|
+
Capability.DELETING,
|
|
355
|
+
Capability.PRESENCE,
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
ZULIP_CAPABILITIES = BackendCapabilities(
|
|
361
|
+
capabilities=frozenset(
|
|
362
|
+
{
|
|
363
|
+
Capability.PLAINTEXT,
|
|
364
|
+
Capability.MARKDOWN,
|
|
365
|
+
Capability.CODE_BLOCKS,
|
|
366
|
+
Capability.IMAGES,
|
|
367
|
+
Capability.FILES,
|
|
368
|
+
Capability.EMOJI_REACTIONS,
|
|
369
|
+
Capability.CUSTOM_EMOJI,
|
|
370
|
+
Capability.THREADS,
|
|
371
|
+
Capability.USER_MENTIONS,
|
|
372
|
+
Capability.CHANNEL_MENTIONS,
|
|
373
|
+
Capability.EDITING,
|
|
374
|
+
Capability.DELETING,
|
|
375
|
+
Capability.PRESENCE,
|
|
376
|
+
}
|
|
377
|
+
),
|
|
378
|
+
max_message_length=10000,
|
|
379
|
+
)
|
|
@@ -175,7 +175,7 @@ class Message(Identifiable):
|
|
|
175
175
|
default_factory=list,
|
|
176
176
|
description="Rich embeds in the message.",
|
|
177
177
|
)
|
|
178
|
-
components: Any
|
|
178
|
+
components: Any = Field(
|
|
179
179
|
default=None,
|
|
180
180
|
description=(
|
|
181
181
|
"Interactive UI components attached to the message. "
|
|
@@ -131,7 +131,7 @@ class MockBackendMixin:
|
|
|
131
131
|
user = self._user_class.model_validate(user_data)
|
|
132
132
|
self._data.mock_users[id] = user
|
|
133
133
|
if hasattr(self, "users") and hasattr(self.users, "add"):
|
|
134
|
-
self.users.add(user) # ty: ignore[
|
|
134
|
+
self.users.add(user) # ty: ignore[not-callable]
|
|
135
135
|
return user
|
|
136
136
|
|
|
137
137
|
def add_mock_channel_data(
|
|
@@ -158,7 +158,7 @@ class MockBackendMixin:
|
|
|
158
158
|
channel = self._channel_class.model_validate(channel_data)
|
|
159
159
|
self._data.mock_channels[id] = channel
|
|
160
160
|
if hasattr(self, "channels") and hasattr(self.channels, "add"):
|
|
161
|
-
self.channels.add(channel) # ty: ignore[
|
|
161
|
+
self.channels.add(channel) # ty: ignore[not-callable]
|
|
162
162
|
if id not in self._data.mock_messages:
|
|
163
163
|
self._data.mock_messages[id] = []
|
|
164
164
|
return channel
|
|
@@ -241,9 +241,9 @@ class MockBackendMixin:
|
|
|
241
241
|
"""Reset all mock data and tracking stores."""
|
|
242
242
|
self._data.reset()
|
|
243
243
|
if hasattr(self, "users") and hasattr(self.users, "clear"):
|
|
244
|
-
self.users.clear() # ty: ignore[
|
|
244
|
+
self.users.clear() # ty: ignore[not-callable]
|
|
245
245
|
if hasattr(self, "channels") and hasattr(self.channels, "clear"):
|
|
246
|
-
self.channels.clear() # ty: ignore[
|
|
246
|
+
self.channels.clear() # ty: ignore[not-callable]
|
|
247
247
|
|
|
248
248
|
@property
|
|
249
249
|
def sent_messages_data(self) -> list[Any]:
|
|
@@ -32,10 +32,12 @@ if HAS_CSP:
|
|
|
32
32
|
from .adapter import BackendAdapter
|
|
33
33
|
from .interactions import interaction_reader
|
|
34
34
|
from .nodes import message_reader, message_writer
|
|
35
|
+
from .runner import BackendRunner
|
|
35
36
|
|
|
36
37
|
__all__ = (
|
|
37
38
|
"HAS_CSP",
|
|
38
39
|
"BackendAdapter",
|
|
40
|
+
"BackendRunner",
|
|
39
41
|
"interaction_reader",
|
|
40
42
|
"message_reader",
|
|
41
43
|
"message_writer",
|
|
@@ -17,6 +17,7 @@ from csp.impl.wiring import py_push_adapter_def
|
|
|
17
17
|
|
|
18
18
|
from ..backend import BackendBase
|
|
19
19
|
from ..base import Interaction
|
|
20
|
+
from .runner import BackendRunner
|
|
20
21
|
|
|
21
22
|
__all__ = (
|
|
22
23
|
"InteractionReaderPushAdapter",
|
|
@@ -64,30 +65,28 @@ class InteractionReaderPushAdapterImpl(PushInputAdapter):
|
|
|
64
65
|
raise self._error
|
|
65
66
|
|
|
66
67
|
def _run(self):
|
|
68
|
+
# Runs on the backend's shared runner, the same connection message_reader uses
|
|
69
|
+
runner = BackendRunner.acquire(self._backend)
|
|
67
70
|
try:
|
|
68
|
-
|
|
71
|
+
runner.call(self._async_run_with_setup).result()
|
|
69
72
|
except Exception as e:
|
|
70
73
|
log.exception("Error in interaction reader: %s", e) # noqa: TRY401
|
|
71
74
|
self._error = e
|
|
72
75
|
self._running_event.clear()
|
|
73
76
|
finally:
|
|
74
77
|
self._queue.put(None)
|
|
78
|
+
runner.release()
|
|
75
79
|
|
|
76
|
-
async def _async_run_with_setup(self):
|
|
80
|
+
async def _async_run_with_setup(self, backend: BackendBase):
|
|
77
81
|
self._loop = asyncio.get_running_loop()
|
|
78
82
|
self._shutdown_event = asyncio.Event()
|
|
79
83
|
try:
|
|
80
|
-
await self._async_run()
|
|
84
|
+
await self._async_run(backend)
|
|
81
85
|
finally:
|
|
82
86
|
self._loop = None
|
|
83
87
|
self._shutdown_event = None
|
|
84
88
|
|
|
85
|
-
async def _async_run(self):
|
|
86
|
-
# Separate backend instance for this thread's loop, same as message_reader
|
|
87
|
-
backend_class = type(self._backend)
|
|
88
|
-
thread_backend = backend_class(config=self._backend.config)
|
|
89
|
-
await thread_backend.connect()
|
|
90
|
-
|
|
89
|
+
async def _async_run(self, thread_backend: BackendBase):
|
|
91
90
|
drain_task = asyncio.create_task(self._drain())
|
|
92
91
|
try:
|
|
93
92
|
try:
|
|
@@ -122,8 +121,6 @@ class InteractionReaderPushAdapterImpl(PushInputAdapter):
|
|
|
122
121
|
drain_task.cancel()
|
|
123
122
|
with contextlib.suppress(asyncio.CancelledError):
|
|
124
123
|
await drain_task
|
|
125
|
-
with contextlib.suppress(Exception):
|
|
126
|
-
await thread_backend.disconnect()
|
|
127
124
|
|
|
128
125
|
async def _consume(self, stream):
|
|
129
126
|
async for event in stream:
|