rusticai-api 1.1.0__tar.gz → 1.2.1__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.
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/PKG-INFO +3 -3
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/pyproject.toml +4 -4
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/api_dependency_manager.py +10 -1
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/guilds/comms_manager.py +57 -4
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/README.md +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/__init__.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/addons/__init__.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/addons/boards/__init__.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/addons/boards/board_store.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/addons/boards/models.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/addons/boards/router.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/addons/boards/schema.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/addons/router.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/catalog/__init__.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/catalog/catalog_store.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/catalog/models.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/catalog/router.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/guilds/__init__.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/guilds/models.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/guilds/router.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/guilds/schema.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/guilds/service.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/guilds/socket.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/guilds/system_comms_manager.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/logging/__init__.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/logging/config.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/logging/format.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/main.py +0 -0
- {rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/main_debug.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rusticai-api
|
|
3
|
-
Version: 1.1
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: API Server for Rustic AI
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Author: Dragonscale Industries Inc.
|
|
@@ -16,8 +16,8 @@ Requires-Dist: psycopg (>=3.2.6,<4.0.0)
|
|
|
16
16
|
Requires-Dist: ptvsd (>=4.3.2,<5.0.0)
|
|
17
17
|
Requires-Dist: python-json-logger (>=3.3.0,<4.0.0)
|
|
18
18
|
Requires-Dist: python-multipart (>=0.0.20,<0.0.21)
|
|
19
|
-
Requires-Dist: rusticai-core (>=1.1
|
|
20
|
-
Requires-Dist: rusticai-ray (>=1.1
|
|
19
|
+
Requires-Dist: rusticai-core (>=1.2.1,<1.3.0)
|
|
20
|
+
Requires-Dist: rusticai-ray (>=1.2.1,<1.3.0)
|
|
21
21
|
Requires-Dist: starlette (>=0.45.3,<0.46.0)
|
|
22
22
|
Requires-Dist: uvicorn (>=0.34.0,<0.35.0)
|
|
23
23
|
Requires-Dist: websockets (>=15.0.1,<16.0.0)
|
|
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "rusticai-api"
|
|
8
|
-
version = "1.1
|
|
8
|
+
version = "1.2.1"
|
|
9
9
|
description = "API Server for Rustic AI"
|
|
10
10
|
authors = [{name = "Dragonscale Industries Inc.", email = "dev@dragonscale.ai"}]
|
|
11
11
|
license = "Apache-2.0"
|
|
@@ -19,8 +19,8 @@ urls = { Homepage = "https://www.rustic.ai/", Repository = "https://github.com/r
|
|
|
19
19
|
packages = [{ include = "rustic_ai", from = "src" }]
|
|
20
20
|
|
|
21
21
|
[tool.poetry.dependencies]
|
|
22
|
-
rusticai-core = { version = "1.1
|
|
23
|
-
rusticai-ray = { version = "1.1
|
|
22
|
+
rusticai-core = { version = "1.2.1"}
|
|
23
|
+
rusticai-ray = { version = "1.2.1"}
|
|
24
24
|
fastapi = "^0.115.8"
|
|
25
25
|
starlette = "^0.45.3"
|
|
26
26
|
uvicorn = "^0.34.0"
|
|
@@ -47,7 +47,7 @@ isort = "^6.0.0"
|
|
|
47
47
|
mypy = "^1.15.0"
|
|
48
48
|
pytest-asyncio = "^0.25.3"
|
|
49
49
|
httpx = "^0.28.1"
|
|
50
|
-
rusticai-testing = { version = "1.1
|
|
50
|
+
rusticai-testing = { version = "1.2.1"}
|
|
51
51
|
|
|
52
52
|
[tool.poetry.extras]
|
|
53
53
|
test = ["pytest", "pytest-asyncio", "httpx", "rusticai-testing"]
|
{rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/api_dependency_manager.py
RENAMED
|
@@ -26,6 +26,7 @@ class ApiDependencyManager:
|
|
|
26
26
|
if not hasattr(self, "initialized"):
|
|
27
27
|
self.dependency_map_cache: Dict[str, Dict[str, DependencySpec]] = {}
|
|
28
28
|
self.dependency_resolver_cache: Dict[str, Dict[str, DependencyResolver]] = {}
|
|
29
|
+
self.org_id_cache: Dict[str, str] = {}
|
|
29
30
|
self.initialized = True
|
|
30
31
|
|
|
31
32
|
def get_dependency(self, dependency_name: str, engine: Engine, guild_id: str, agent_id: Optional[str] = None):
|
|
@@ -57,6 +58,7 @@ class ApiDependencyManager:
|
|
|
57
58
|
guild_spec = guild_model.to_guild_spec()
|
|
58
59
|
|
|
59
60
|
self.dependency_map_cache[guild_id] = GuildHelper.get_guild_dependency_map(guild_spec)
|
|
61
|
+
self.org_id_cache[guild_id] = guild_model.organization_id
|
|
60
62
|
|
|
61
63
|
if dependency_name not in self.dependency_map_cache[guild_id]: # pragma: no cover
|
|
62
64
|
raise HTTPException(
|
|
@@ -71,7 +73,14 @@ class ApiDependencyManager:
|
|
|
71
73
|
)
|
|
72
74
|
|
|
73
75
|
resolver = self.dependency_resolver_cache[guild_id][dependency_name]
|
|
74
|
-
|
|
76
|
+
# Get org_id from cache, or load it if not available
|
|
77
|
+
if guild_id not in self.org_id_cache:
|
|
78
|
+
guild_store = GuildStore(engine)
|
|
79
|
+
guild_model = guild_store.get_guild(guild_id)
|
|
80
|
+
if guild_model:
|
|
81
|
+
self.org_id_cache[guild_id] = guild_model.organization_id
|
|
82
|
+
org_id = self.org_id_cache.get(guild_id, guild_id) # Fallback to guild_id if still not available
|
|
83
|
+
dependency = resolver.get_or_resolve(org_id, guild_id, agent_id)
|
|
75
84
|
|
|
76
85
|
return dependency
|
|
77
86
|
|
|
@@ -92,7 +92,14 @@ class GuildCommunicationManager:
|
|
|
92
92
|
loop: asyncio.AbstractEventLoop,
|
|
93
93
|
) -> Callable[[Message], None]:
|
|
94
94
|
def on_message(message: Message) -> None:
|
|
95
|
-
logging.debug(
|
|
95
|
+
logging.debug(
|
|
96
|
+
"Websocket delivery candidate guild=%s user=%s message_id=%s topic=%s sender=%s",
|
|
97
|
+
guild_id,
|
|
98
|
+
user_id,
|
|
99
|
+
message.id,
|
|
100
|
+
message.topic_published_to,
|
|
101
|
+
message.sender.id if message.sender else None,
|
|
102
|
+
)
|
|
96
103
|
|
|
97
104
|
try:
|
|
98
105
|
coroutine = self.send_message(guild_id, user_id, message, websocket)
|
|
@@ -155,9 +162,22 @@ class GuildCommunicationManager:
|
|
|
155
162
|
messaging: MessagingInterface = await self.get_or_create_messaging_interface(guild_spec)
|
|
156
163
|
guild_client: Client = await self.create_guild_client(guild_id, user_id, messaging, websocket, loop)
|
|
157
164
|
messaging.subscribe(UserProxyAgent.get_user_notifications_topic(user_id), guild_client)
|
|
165
|
+
logging.debug(
|
|
166
|
+
"Registered websocket client id=%s guild=%s user=%s notifications_topic=%s",
|
|
167
|
+
guild_client.id,
|
|
168
|
+
guild_id,
|
|
169
|
+
user_id,
|
|
170
|
+
UserProxyAgent.get_user_notifications_topic(user_id),
|
|
171
|
+
)
|
|
158
172
|
|
|
159
173
|
user_agent_tag = AgentTag(id=self.get_socket_agent_id(user_id), name=user_name)
|
|
160
174
|
|
|
175
|
+
logging.debug(
|
|
176
|
+
"Publishing user agent creation request guild=%s user=%s topic=%s",
|
|
177
|
+
guild_id,
|
|
178
|
+
user_id,
|
|
179
|
+
GuildTopics.SYSTEM_TOPIC,
|
|
180
|
+
)
|
|
161
181
|
guild_client.publish(
|
|
162
182
|
Message(
|
|
163
183
|
self._gemstone.get_id(Priority.NORMAL),
|
|
@@ -220,7 +240,15 @@ class GuildCommunicationManager:
|
|
|
220
240
|
message_history = [ProcessEntry.model_validate(entry) for entry in history]
|
|
221
241
|
|
|
222
242
|
try:
|
|
223
|
-
logging.debug(
|
|
243
|
+
logging.debug(
|
|
244
|
+
"Websocket ingress guild=%s user=%s normalized_id=%s inbox_topic=%s thread=%s format=%s",
|
|
245
|
+
guild_id,
|
|
246
|
+
user_id,
|
|
247
|
+
data["id"],
|
|
248
|
+
UserProxyAgent.get_user_inbox_topic(user_id),
|
|
249
|
+
data["thread"],
|
|
250
|
+
data.get("format", "UNKNOWN"),
|
|
251
|
+
)
|
|
224
252
|
message = Message(
|
|
225
253
|
idg,
|
|
226
254
|
topics=UserProxyAgent.get_user_inbox_topic(user_id),
|
|
@@ -232,7 +260,13 @@ class GuildCommunicationManager:
|
|
|
232
260
|
message_history=message_history,
|
|
233
261
|
)
|
|
234
262
|
|
|
235
|
-
logging.debug(
|
|
263
|
+
logging.debug(
|
|
264
|
+
"Publishing websocket ingress message guild=%s user=%s message_id=%s topic=%s",
|
|
265
|
+
guild_id,
|
|
266
|
+
user_id,
|
|
267
|
+
message.id,
|
|
268
|
+
UserProxyAgent.get_user_inbox_topic(user_id),
|
|
269
|
+
)
|
|
236
270
|
|
|
237
271
|
if message:
|
|
238
272
|
guild_client.publish(message)
|
|
@@ -258,6 +292,25 @@ class GuildCommunicationManager:
|
|
|
258
292
|
result = True
|
|
259
293
|
return result
|
|
260
294
|
|
|
295
|
+
@staticmethod
|
|
296
|
+
def historical_message_sort_key(message: Message) -> tuple[int, int, bool, int, int]:
|
|
297
|
+
"""
|
|
298
|
+
Prefer chronological ordering, but keep messages from the same interaction in causal order.
|
|
299
|
+
|
|
300
|
+
Different agents can generate IDs in the same millisecond with different machine IDs, which can
|
|
301
|
+
invert user-message/agent-response pairs if we sort purely by message ID.
|
|
302
|
+
"""
|
|
303
|
+
# Any message that explicitly responds to an earlier message should come after
|
|
304
|
+
# the user-originated entry for that interaction, even if it shares the same root.
|
|
305
|
+
is_follow_up = message.in_response_to is not None
|
|
306
|
+
return (
|
|
307
|
+
message.timestamp,
|
|
308
|
+
message.root_thread_id,
|
|
309
|
+
is_follow_up,
|
|
310
|
+
len(message.message_history),
|
|
311
|
+
message.id,
|
|
312
|
+
)
|
|
313
|
+
|
|
261
314
|
async def get_historical_user_notifications(self, guild_id: str, user_id: str, engine: Engine) -> List[Message]:
|
|
262
315
|
guild_spec = await self.get_or_fetch_guild_spec(guild_id, engine)
|
|
263
316
|
|
|
@@ -279,7 +332,7 @@ class GuildCommunicationManager:
|
|
|
279
332
|
]
|
|
280
333
|
# Combine and sort messages
|
|
281
334
|
all_messages = user_msgs + filtered_broadcast_msgs
|
|
282
|
-
result = sorted(all_messages, key=
|
|
335
|
+
result = sorted(all_messages, key=self.historical_message_sort_key)
|
|
283
336
|
logging.debug(f"Retrieved {len(result)} messages")
|
|
284
337
|
return result
|
|
285
338
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/addons/boards/__init__.py
RENAMED
|
File without changes
|
{rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/addons/boards/board_store.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rusticai_api-1.1.0 → rusticai_api-1.2.1}/src/rustic_ai/api_server/guilds/system_comms_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|