agent-office-cli 0.1.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.
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-office-cli
3
+ Version: 0.1.0
4
+ Summary: Human-centered multi-department office workflow, request management, and conversation adapter framework for AI agents
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/IT-Engineer-K/Agent-Office
7
+ Project-URL: Repository, https://github.com/IT-Engineer-K/Agent-Office
8
+ Project-URL: Issues, https://github.com/IT-Engineer-K/Agent-Office/issues
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: discord-message-cli>=0.3.0
19
+
20
+ # Agent Office (`agent-office-cli`)
21
+
22
+ 人間を中心に据えつつ、部署ごとの AI エージェント(マネージャー役・部下役)が並列に協調し、要望受付・質問すり合わせ・委譲・完了報告を行うためのオフィス基盤 CLI(`agent-office`)兼 Python ライブラリ(`agent_office`)です。
23
+
24
+ ## 設計の特徴
25
+
26
+ - **`discord-msg` との責務分離**: Discord の低レベル通信は [`discord-message-cli`](https://pypi.org/project/discord-message-cli/) (`discord_msg >= 0.3.0`) へ委譲し、Agent Office は `ConversationAdapter` を介して `REQ-ID`・部署窓口(`Desk`)・登場人物(`Actor`)・ステータス遷移・SQLite 永続化を管理します。
27
+ - **人間中心&複数部署の並列協調に対応**:
28
+ - `Desk`(各部署の窓口=チャンネル。登録済みチャンネルのみアクセス可能な allowlist として機能)
29
+ - `Actor`(`human` / `manager` / `worker`)
30
+ - `Request`(`REQ-0001` 形式の連番、`parent_req_id` による親子タスク委譲、`OPEN` / `CLARIFYING` / `WAITING_HUMAN` / `IN_PROGRESS` / `DONE` / `CANCELLED`)
31
+ - `RequestEvent`(質問・回答・状態変更の監査ログ)
32
+ - **再開可能なカーソル管理**: 受付チャンネルの `inbox_cursor` と各スレッドの `thread_cursor` を SQLite へ永続化し、プロセス再起動後も同じ位置から再開できます。
33
+
34
+ ## 導入
35
+
36
+ ```powershell
37
+ pip install agent-office-cli
38
+ ```
39
+
40
+ ローカルで開発する場合はリポジトリ直下で以下を実行してください。
41
+
42
+ ```powershell
43
+ pip install -e .
44
+ ```
45
+
46
+ Discord と連携する場合は事前に `DISCORD_BOT_TOKEN` 環境変数を設定してください(`discord-msg setup` でも設定可能です)。
47
+
48
+ ## 基本的な使い方(CLI)
49
+
50
+ 全コマンドで `--format json`(AI エージェント向け)と `--format table`(人間向け・既定)を利用できます。
51
+
52
+ ```powershell
53
+ # 1. 部署窓口(Desk)と登場人物(Actor)を登録
54
+ agent-office desk add dev --channel 123456789012345678 --name "開発部"
55
+ agent-office actor add owner --role human --name "オーナー" --external-user-id 222333444555666777
56
+ agent-office actor add dev-manager --role manager --name "開発マネージャー" --desk dev
57
+
58
+ # 2. 受付チャンネルの新着メッセージから REQ-ID を発番
59
+ agent-office inbox pull --desk dev --format json
60
+
61
+ # 3. 質問を送信(スレッド未作成なら自動作成、ステータスは CLARIFYING へ)
62
+ agent-office req ask REQ-0001 "優先度は高・中・低のどれにしますか?" --actor dev-manager --format json
63
+
64
+ # 4. 提案者の返信を待機(タイムアウトしてもカーソルを保存して終了コード 0)
65
+ agent-office req wait REQ-0001 --timeout 60 --format json
66
+
67
+ # 5. 進捗報告や完了報告(ステータス同時更新)
68
+ agent-office req reply REQ-0001 "実装とテストが完了しました。" --actor dev-manager --status DONE --format json
69
+ ```
70
+
71
+ ## Python API の利用例
72
+
73
+ ```python
74
+ from agent_office import AgentOfficeService, DiscordConversationAdapter, SQLiteStore
75
+
76
+ with SQLiteStore() as store:
77
+ svc = AgentOfficeService(store, DiscordConversationAdapter())
78
+ pulled = svc.pull_inbox("dev")
79
+ for req in pulled.created_requests:
80
+ svc.ask(req.req_id, "詳細要件を確認させてください。", actor_id="dev-manager")
81
+ waited = svc.wait_for_answer(req.req_id, timeout=60.0)
82
+ if not waited.timed_out:
83
+ svc.reply(req.req_id, "承知しました。作業を開始します。", actor_id="dev-manager", status="IN_PROGRESS")
84
+ ```
85
+
86
+ ## テストの実行
87
+
88
+ テストは `InMemoryConversationAdapter` およびモック `HttpTransport` を使用するため、外部通信なしで実行できます。
89
+
90
+ ```powershell
91
+ $env:PYTHONPATH="src"
92
+ python -m unittest discover -s tests -v
93
+ ```
@@ -0,0 +1,74 @@
1
+ # Agent Office (`agent-office-cli`)
2
+
3
+ 人間を中心に据えつつ、部署ごとの AI エージェント(マネージャー役・部下役)が並列に協調し、要望受付・質問すり合わせ・委譲・完了報告を行うためのオフィス基盤 CLI(`agent-office`)兼 Python ライブラリ(`agent_office`)です。
4
+
5
+ ## 設計の特徴
6
+
7
+ - **`discord-msg` との責務分離**: Discord の低レベル通信は [`discord-message-cli`](https://pypi.org/project/discord-message-cli/) (`discord_msg >= 0.3.0`) へ委譲し、Agent Office は `ConversationAdapter` を介して `REQ-ID`・部署窓口(`Desk`)・登場人物(`Actor`)・ステータス遷移・SQLite 永続化を管理します。
8
+ - **人間中心&複数部署の並列協調に対応**:
9
+ - `Desk`(各部署の窓口=チャンネル。登録済みチャンネルのみアクセス可能な allowlist として機能)
10
+ - `Actor`(`human` / `manager` / `worker`)
11
+ - `Request`(`REQ-0001` 形式の連番、`parent_req_id` による親子タスク委譲、`OPEN` / `CLARIFYING` / `WAITING_HUMAN` / `IN_PROGRESS` / `DONE` / `CANCELLED`)
12
+ - `RequestEvent`(質問・回答・状態変更の監査ログ)
13
+ - **再開可能なカーソル管理**: 受付チャンネルの `inbox_cursor` と各スレッドの `thread_cursor` を SQLite へ永続化し、プロセス再起動後も同じ位置から再開できます。
14
+
15
+ ## 導入
16
+
17
+ ```powershell
18
+ pip install agent-office-cli
19
+ ```
20
+
21
+ ローカルで開発する場合はリポジトリ直下で以下を実行してください。
22
+
23
+ ```powershell
24
+ pip install -e .
25
+ ```
26
+
27
+ Discord と連携する場合は事前に `DISCORD_BOT_TOKEN` 環境変数を設定してください(`discord-msg setup` でも設定可能です)。
28
+
29
+ ## 基本的な使い方(CLI)
30
+
31
+ 全コマンドで `--format json`(AI エージェント向け)と `--format table`(人間向け・既定)を利用できます。
32
+
33
+ ```powershell
34
+ # 1. 部署窓口(Desk)と登場人物(Actor)を登録
35
+ agent-office desk add dev --channel 123456789012345678 --name "開発部"
36
+ agent-office actor add owner --role human --name "オーナー" --external-user-id 222333444555666777
37
+ agent-office actor add dev-manager --role manager --name "開発マネージャー" --desk dev
38
+
39
+ # 2. 受付チャンネルの新着メッセージから REQ-ID を発番
40
+ agent-office inbox pull --desk dev --format json
41
+
42
+ # 3. 質問を送信(スレッド未作成なら自動作成、ステータスは CLARIFYING へ)
43
+ agent-office req ask REQ-0001 "優先度は高・中・低のどれにしますか?" --actor dev-manager --format json
44
+
45
+ # 4. 提案者の返信を待機(タイムアウトしてもカーソルを保存して終了コード 0)
46
+ agent-office req wait REQ-0001 --timeout 60 --format json
47
+
48
+ # 5. 進捗報告や完了報告(ステータス同時更新)
49
+ agent-office req reply REQ-0001 "実装とテストが完了しました。" --actor dev-manager --status DONE --format json
50
+ ```
51
+
52
+ ## Python API の利用例
53
+
54
+ ```python
55
+ from agent_office import AgentOfficeService, DiscordConversationAdapter, SQLiteStore
56
+
57
+ with SQLiteStore() as store:
58
+ svc = AgentOfficeService(store, DiscordConversationAdapter())
59
+ pulled = svc.pull_inbox("dev")
60
+ for req in pulled.created_requests:
61
+ svc.ask(req.req_id, "詳細要件を確認させてください。", actor_id="dev-manager")
62
+ waited = svc.wait_for_answer(req.req_id, timeout=60.0)
63
+ if not waited.timed_out:
64
+ svc.reply(req.req_id, "承知しました。作業を開始します。", actor_id="dev-manager", status="IN_PROGRESS")
65
+ ```
66
+
67
+ ## テストの実行
68
+
69
+ テストは `InMemoryConversationAdapter` およびモック `HttpTransport` を使用するため、外部通信なしで実行できます。
70
+
71
+ ```powershell
72
+ $env:PYTHONPATH="src"
73
+ python -m unittest discover -s tests -v
74
+ ```
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-office-cli"
7
+ version = "0.1.0"
8
+ description = "Human-centered multi-department office workflow, request management, and conversation adapter framework for AI agents"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {text = "MIT"}
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Developers",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ ]
21
+ dependencies = [
22
+ "discord-message-cli>=0.3.0",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/IT-Engineer-K/Agent-Office"
27
+ Repository = "https://github.com/IT-Engineer-K/Agent-Office"
28
+ Issues = "https://github.com/IT-Engineer-K/Agent-Office/issues"
29
+
30
+ [project.scripts]
31
+ agent-office = "agent_office.cli:main"
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,73 @@
1
+ """Agent Office — Human-centered multi-department workflow and conversation adapter library."""
2
+
3
+ from .adapters import (
4
+ ConversationAdapter,
5
+ DiscordConversationAdapter,
6
+ InMemoryConversationAdapter,
7
+ )
8
+ from .errors import (
9
+ AdapterError,
10
+ AgentOfficeError,
11
+ ChannelNotAllowedError,
12
+ ConflictError,
13
+ ExitCode,
14
+ InvalidArgumentsError,
15
+ NotFoundError,
16
+ StorageError,
17
+ )
18
+ from .models import (
19
+ Actor,
20
+ ActorRole,
21
+ AskResult,
22
+ CreatedThread,
23
+ Desk,
24
+ EventType,
25
+ InboxPullResult,
26
+ IncomingMessage,
27
+ MessageBatch,
28
+ PostedMessage,
29
+ RepliesResult,
30
+ ReplyResult,
31
+ Request,
32
+ RequestEvent,
33
+ RequestStatus,
34
+ WaitBatch,
35
+ )
36
+ from .service import AgentOfficeService
37
+ from .store import SQLiteStore, default_db_path
38
+
39
+ __version__ = "0.1.0"
40
+
41
+ __all__ = [
42
+ "__version__",
43
+ "AgentOfficeService",
44
+ "SQLiteStore",
45
+ "default_db_path",
46
+ "ConversationAdapter",
47
+ "DiscordConversationAdapter",
48
+ "InMemoryConversationAdapter",
49
+ "Desk",
50
+ "Actor",
51
+ "ActorRole",
52
+ "Request",
53
+ "RequestStatus",
54
+ "RequestEvent",
55
+ "EventType",
56
+ "PostedMessage",
57
+ "CreatedThread",
58
+ "IncomingMessage",
59
+ "MessageBatch",
60
+ "WaitBatch",
61
+ "InboxPullResult",
62
+ "AskResult",
63
+ "RepliesResult",
64
+ "ReplyResult",
65
+ "ExitCode",
66
+ "AgentOfficeError",
67
+ "InvalidArgumentsError",
68
+ "NotFoundError",
69
+ "ConflictError",
70
+ "ChannelNotAllowedError",
71
+ "AdapterError",
72
+ "StorageError",
73
+ ]
@@ -0,0 +1,11 @@
1
+ """Conversation adapter implementations for Agent Office."""
2
+
3
+ from .base import ConversationAdapter
4
+ from .discord import DiscordConversationAdapter
5
+ from .memory import InMemoryConversationAdapter
6
+
7
+ __all__ = [
8
+ "ConversationAdapter",
9
+ "DiscordConversationAdapter",
10
+ "InMemoryConversationAdapter",
11
+ ]
@@ -0,0 +1,76 @@
1
+ """Abstract conversation adapter protocol for Agent Office."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Protocol
6
+
7
+ from ..models import CreatedThread, MessageBatch, PostedMessage, WaitBatch
8
+
9
+
10
+ class ConversationAdapter(Protocol):
11
+ """Platform-agnostic messaging interface used by AgentOfficeService."""
12
+
13
+ adapter_type: str
14
+
15
+ def allow_channel(self, channel_id: str) -> None:
16
+ """Register a channel ID in the adapter's allowlist (if enforced)."""
17
+ ...
18
+
19
+ def allow_thread(self, thread_id: str) -> None:
20
+ """Register a thread ID in the adapter's allowlist (if enforced)."""
21
+ ...
22
+
23
+ def post_message(
24
+ self,
25
+ channel_id: str,
26
+ content: str,
27
+ *,
28
+ allow_mentions: bool = False,
29
+ ) -> PostedMessage:
30
+ """Post a message to a top-level channel."""
31
+ ...
32
+
33
+ def create_thread(
34
+ self,
35
+ channel_id: str,
36
+ message_id: str,
37
+ name: str,
38
+ ) -> CreatedThread:
39
+ """Create a thread anchored to an existing channel message."""
40
+ ...
41
+
42
+ def send_to_thread(
43
+ self,
44
+ thread_id: str,
45
+ content: str,
46
+ *,
47
+ allow_mentions: bool = False,
48
+ ) -> PostedMessage:
49
+ """Post a message inside an existing thread."""
50
+ ...
51
+
52
+ def list_messages(
53
+ self,
54
+ *,
55
+ channel_id: str | None = None,
56
+ thread_id: str | None = None,
57
+ after: str | None = None,
58
+ limit: int = 50,
59
+ author_id: str | None = None,
60
+ exclude_bots: bool = False,
61
+ ) -> MessageBatch:
62
+ """List messages in a channel or thread after an optional cursor."""
63
+ ...
64
+
65
+ def wait_for_messages(
66
+ self,
67
+ *,
68
+ thread_id: str,
69
+ after: str | None = None,
70
+ timeout: float = 60.0,
71
+ poll_interval: float = 2.0,
72
+ author_id: str | None = None,
73
+ exclude_bots: bool = False,
74
+ ) -> WaitBatch:
75
+ """Wait for new matching messages in a thread until timeout."""
76
+ ...
@@ -0,0 +1,254 @@
1
+ """Discord ConversationAdapter backed by discord-message-cli (discord_msg)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from collections.abc import Collection, Mapping
7
+ from typing import Any
8
+
9
+ from discord_msg import (
10
+ DiscordClient,
11
+ DiscordMsgError,
12
+ HttpTransport,
13
+ MessageItem,
14
+ )
15
+ from discord_msg.auth import DEFAULT_TOKEN_ENV, resolve_token
16
+
17
+ from ..errors import AdapterError, ChannelNotAllowedError, InvalidArgumentsError
18
+ from ..models import (
19
+ CreatedThread,
20
+ IncomingMessage,
21
+ MessageBatch,
22
+ PostedMessage,
23
+ WaitBatch,
24
+ )
25
+
26
+
27
+ def _to_incoming(item: MessageItem) -> IncomingMessage:
28
+ return IncomingMessage(
29
+ message_id=item.message_id,
30
+ channel_id=item.channel_id,
31
+ author_id=item.author_id,
32
+ author_name=item.author_display_name or item.author_username or item.author_id,
33
+ author_bot=item.author_bot,
34
+ timestamp=item.timestamp,
35
+ content=item.content,
36
+ referenced_message_id=item.referenced_message_id,
37
+ )
38
+
39
+
40
+ class DiscordConversationAdapter:
41
+ """ConversationAdapter implementation delegating to discord_msg.DiscordClient."""
42
+
43
+ adapter_type: str = "discord"
44
+
45
+ def __init__(
46
+ self,
47
+ *,
48
+ client: DiscordClient | None = None,
49
+ token: str | None = None,
50
+ transport: HttpTransport | None = None,
51
+ env: Mapping[str, str] | None = None,
52
+ allowed_channels: Collection[str] | None = None,
53
+ allowed_threads: Collection[str] | None = None,
54
+ enforce_allowlist: bool = True,
55
+ ) -> None:
56
+ self._client: DiscordClient | None = client
57
+ self._token = token
58
+ self._transport = transport
59
+ self._env = env
60
+ self._enforce_allowlist = enforce_allowlist
61
+ self._allowed_channels: set[str] = set(allowed_channels or ())
62
+ self._allowed_threads: set[str] = set(allowed_threads or ())
63
+
64
+ def _get_client(self) -> DiscordClient:
65
+ if self._client is not None:
66
+ return self._client
67
+ try:
68
+ if self._token is not None and self._token.strip():
69
+ resolved_token = self._token.strip()
70
+ if resolved_token.lower().startswith("bot "):
71
+ resolved_token = resolved_token[4:].strip()
72
+ else:
73
+ environ = self._env if self._env is not None else os.environ
74
+ resolved_token = resolve_token(
75
+ prompt_token=False,
76
+ token_stdin=False,
77
+ env_var=DEFAULT_TOKEN_ENV,
78
+ env=environ,
79
+ stdin=None,
80
+ )
81
+ self._client = DiscordClient(resolved_token, transport=self._transport)
82
+ return self._client
83
+ except DiscordMsgError as exc:
84
+ raise AdapterError(f"Discord auth/init failed ({exc.code}): {exc.message}") from exc
85
+
86
+ def allow_channel(self, channel_id: str) -> None:
87
+ cleaned = channel_id.strip()
88
+ if cleaned:
89
+ self._allowed_channels.add(cleaned)
90
+
91
+ def allow_thread(self, thread_id: str) -> None:
92
+ cleaned = thread_id.strip()
93
+ if cleaned:
94
+ self._allowed_threads.add(cleaned)
95
+
96
+ def _check_channel(self, channel_id: str) -> str:
97
+ cleaned = channel_id.strip()
98
+ if not cleaned:
99
+ raise InvalidArgumentsError("channel_id must not be empty.")
100
+ if self._enforce_allowlist and cleaned not in self._allowed_channels:
101
+ raise ChannelNotAllowedError(
102
+ f"Channel '{cleaned}' is not in the Agent Office allowlist."
103
+ )
104
+ return cleaned
105
+
106
+ def _check_thread(self, thread_id: str) -> str:
107
+ cleaned = thread_id.strip()
108
+ if not cleaned:
109
+ raise InvalidArgumentsError("thread_id must not be empty.")
110
+ if (
111
+ self._enforce_allowlist
112
+ and cleaned not in self._allowed_threads
113
+ and cleaned not in self._allowed_channels
114
+ ):
115
+ raise ChannelNotAllowedError(
116
+ f"Thread '{cleaned}' is not in the Agent Office allowlist."
117
+ )
118
+ return cleaned
119
+
120
+ def post_message(
121
+ self,
122
+ channel_id: str,
123
+ content: str,
124
+ *,
125
+ allow_mentions: bool = False,
126
+ ) -> PostedMessage:
127
+ cid = self._check_channel(channel_id)
128
+ try:
129
+ res = self._get_client().send_message(
130
+ cid,
131
+ content,
132
+ allow_mentions=allow_mentions,
133
+ )
134
+ except DiscordMsgError as exc:
135
+ raise AdapterError(f"Discord post_message failed ({exc.code}): {exc.message}") from exc
136
+ return PostedMessage(
137
+ channel_id=res.channel_id,
138
+ message_id=res.message_id,
139
+ timestamp=res.timestamp,
140
+ )
141
+
142
+ def create_thread(
143
+ self,
144
+ channel_id: str,
145
+ message_id: str,
146
+ name: str,
147
+ ) -> CreatedThread:
148
+ cid = self._check_channel(channel_id)
149
+ try:
150
+ res = self._get_client().create_thread(cid, message_id, name)
151
+ except DiscordMsgError as exc:
152
+ raise AdapterError(f"Discord create_thread failed ({exc.code}): {exc.message}") from exc
153
+ self._allowed_threads.add(res.thread_id)
154
+ return CreatedThread(
155
+ thread_id=res.thread_id,
156
+ parent_channel_id=res.parent_channel_id,
157
+ source_message_id=res.source_message_id,
158
+ name=res.name,
159
+ )
160
+
161
+ def send_to_thread(
162
+ self,
163
+ thread_id: str,
164
+ content: str,
165
+ *,
166
+ allow_mentions: bool = False,
167
+ ) -> PostedMessage:
168
+ tid = self._check_thread(thread_id)
169
+ try:
170
+ res = self._get_client().send_message(
171
+ thread_id=tid,
172
+ content=content,
173
+ allow_mentions=allow_mentions,
174
+ )
175
+ except DiscordMsgError as exc:
176
+ raise AdapterError(f"Discord send_to_thread failed ({exc.code}): {exc.message}") from exc
177
+ return PostedMessage(
178
+ channel_id=res.channel_id,
179
+ message_id=res.message_id,
180
+ timestamp=res.timestamp,
181
+ )
182
+
183
+ def list_messages(
184
+ self,
185
+ *,
186
+ channel_id: str | None = None,
187
+ thread_id: str | None = None,
188
+ after: str | None = None,
189
+ limit: int = 50,
190
+ author_id: str | None = None,
191
+ exclude_bots: bool = False,
192
+ ) -> MessageBatch:
193
+ if channel_id and thread_id:
194
+ raise InvalidArgumentsError("Specify either channel_id or thread_id, not both.")
195
+ if not channel_id and not thread_id:
196
+ raise InvalidArgumentsError("Either channel_id or thread_id is required.")
197
+
198
+ kwargs: dict[str, Any] = {
199
+ "after": after,
200
+ "limit": limit,
201
+ "author_id": author_id,
202
+ "exclude_bots": exclude_bots,
203
+ }
204
+ if channel_id:
205
+ kwargs["channel_id"] = self._check_channel(channel_id)
206
+ else:
207
+ assert thread_id is not None
208
+ kwargs["thread_id"] = self._check_thread(thread_id)
209
+
210
+ try:
211
+ res = self._get_client().list_messages(**kwargs)
212
+ except DiscordMsgError as exc:
213
+ raise AdapterError(f"Discord list_messages failed ({exc.code}): {exc.message}") from exc
214
+
215
+ return MessageBatch(
216
+ channel_id=res.channel_id,
217
+ after=res.after,
218
+ cursor=res.cursor,
219
+ messages=tuple(_to_incoming(m) for m in res.messages),
220
+ )
221
+
222
+ def wait_for_messages(
223
+ self,
224
+ *,
225
+ thread_id: str,
226
+ after: str | None = None,
227
+ timeout: float = 60.0,
228
+ poll_interval: float = 2.0,
229
+ author_id: str | None = None,
230
+ exclude_bots: bool = False,
231
+ ) -> WaitBatch:
232
+ tid = self._check_thread(thread_id)
233
+ try:
234
+ res = self._get_client().wait_for_messages(
235
+ thread_id=tid,
236
+ after=after,
237
+ timeout=timeout,
238
+ poll_interval=poll_interval,
239
+ author_id=author_id,
240
+ exclude_bots=exclude_bots,
241
+ )
242
+ except DiscordMsgError as exc:
243
+ raise AdapterError(
244
+ f"Discord wait_for_messages failed ({exc.code}): {exc.message}"
245
+ ) from exc
246
+
247
+ return WaitBatch(
248
+ channel_id=res.channel_id,
249
+ after=res.after,
250
+ cursor=res.cursor,
251
+ messages=tuple(_to_incoming(m) for m in res.messages),
252
+ timed_out=res.timed_out,
253
+ polls=res.polls,
254
+ )