connectonion 0.5.9__py3-none-any.whl → 0.5.10__py3-none-any.whl
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.
- connectonion/__init__.py +1 -1
- connectonion/host.py +23 -11
- {connectonion-0.5.9.dist-info → connectonion-0.5.10.dist-info}/METADATA +1 -1
- {connectonion-0.5.9.dist-info → connectonion-0.5.10.dist-info}/RECORD +6 -6
- {connectonion-0.5.9.dist-info → connectonion-0.5.10.dist-info}/WHEEL +0 -0
- {connectonion-0.5.9.dist-info → connectonion-0.5.10.dist-info}/entry_points.txt +0 -0
connectonion/__init__.py
CHANGED
connectonion/host.py
CHANGED
|
@@ -9,7 +9,13 @@ Trust parameter accepts three forms:
|
|
|
9
9
|
3. Agent: Custom Agent instance for verification
|
|
10
10
|
|
|
11
11
|
All forms create a trust agent behind the scenes.
|
|
12
|
+
|
|
13
|
+
Worker Isolation:
|
|
14
|
+
Each request gets a fresh deep copy of the agent template.
|
|
15
|
+
This ensures complete isolation - tools with state (like BrowserTool)
|
|
16
|
+
don't interfere between concurrent requests.
|
|
12
17
|
"""
|
|
18
|
+
import copy
|
|
13
19
|
import hashlib
|
|
14
20
|
import json
|
|
15
21
|
import logging
|
|
@@ -102,17 +108,18 @@ class SessionStorage:
|
|
|
102
108
|
|
|
103
109
|
# === Handlers (pure functions) ===
|
|
104
110
|
|
|
105
|
-
def input_handler(
|
|
111
|
+
def input_handler(agent_template, storage: SessionStorage, prompt: str, result_ttl: int,
|
|
106
112
|
session: dict | None = None) -> dict:
|
|
107
113
|
"""POST /input
|
|
108
114
|
|
|
109
115
|
Args:
|
|
110
|
-
|
|
116
|
+
agent_template: The agent template (deep copied per request for isolation)
|
|
111
117
|
storage: SessionStorage for persisting results
|
|
112
118
|
prompt: The user's prompt
|
|
113
119
|
result_ttl: How long to keep the result on server
|
|
114
120
|
session: Optional conversation session for continuation
|
|
115
121
|
"""
|
|
122
|
+
agent = copy.deepcopy(agent_template)
|
|
116
123
|
now = time.time()
|
|
117
124
|
|
|
118
125
|
# Get or generate session_id
|
|
@@ -393,23 +400,27 @@ def admin_sessions_handler() -> dict:
|
|
|
393
400
|
|
|
394
401
|
# === Entry Point ===
|
|
395
402
|
|
|
396
|
-
def _create_handlers(
|
|
403
|
+
def _create_handlers(agent_template, result_ttl: int):
|
|
397
404
|
"""Create handler dict for ASGI app."""
|
|
405
|
+
def ws_input(prompt: str) -> str:
|
|
406
|
+
agent = copy.deepcopy(agent_template)
|
|
407
|
+
return agent.input(prompt)
|
|
408
|
+
|
|
398
409
|
return {
|
|
399
|
-
"input": lambda storage, prompt, ttl, session=None: input_handler(
|
|
410
|
+
"input": lambda storage, prompt, ttl, session=None: input_handler(agent_template, storage, prompt, ttl, session),
|
|
400
411
|
"session": session_handler,
|
|
401
412
|
"sessions": sessions_handler,
|
|
402
|
-
"health": lambda start_time: health_handler(
|
|
403
|
-
"info": lambda trust: info_handler(
|
|
413
|
+
"health": lambda start_time: health_handler(agent_template, start_time),
|
|
414
|
+
"info": lambda trust: info_handler(agent_template, trust),
|
|
404
415
|
"auth": extract_and_authenticate,
|
|
405
|
-
"ws_input":
|
|
416
|
+
"ws_input": ws_input,
|
|
406
417
|
# Admin endpoints (auth required via OPENONION_API_KEY)
|
|
407
|
-
"admin_logs": lambda: admin_logs_handler(
|
|
418
|
+
"admin_logs": lambda: admin_logs_handler(agent_template.name),
|
|
408
419
|
"admin_sessions": admin_sessions_handler,
|
|
409
420
|
}
|
|
410
421
|
|
|
411
422
|
|
|
412
|
-
def _start_relay_background(
|
|
423
|
+
def _start_relay_background(agent_template, relay_url: str, addr_data: dict):
|
|
413
424
|
"""Start relay connection in background thread.
|
|
414
425
|
|
|
415
426
|
The relay connection runs alongside the HTTP server, allowing the agent
|
|
@@ -420,11 +431,12 @@ def _start_relay_background(agent, relay_url: str, addr_data: dict):
|
|
|
420
431
|
from . import announce, relay
|
|
421
432
|
|
|
422
433
|
# Create ANNOUNCE message
|
|
423
|
-
summary =
|
|
434
|
+
summary = agent_template.system_prompt[:1000] if agent_template.system_prompt else f"{agent_template.name} agent"
|
|
424
435
|
announce_msg = announce.create_announce_message(addr_data, summary, endpoints=[])
|
|
425
436
|
|
|
426
|
-
# Task handler
|
|
437
|
+
# Task handler - deep copy for each request
|
|
427
438
|
async def task_handler(prompt: str) -> str:
|
|
439
|
+
agent = copy.deepcopy(agent_template)
|
|
428
440
|
return agent.input(prompt)
|
|
429
441
|
|
|
430
442
|
async def relay_loop():
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: connectonion
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.10
|
|
4
4
|
Summary: A simple Python framework for creating AI agents with behavior tracking
|
|
5
5
|
Project-URL: Homepage, https://github.com/openonion/connectonion
|
|
6
6
|
Project-URL: Documentation, https://docs.connectonion.com
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
connectonion/__init__.py,sha256=
|
|
1
|
+
connectonion/__init__.py,sha256=VHZugKSYm3j_qeLiLS93Ee7mqJJ0uPvl9BtLRkKJkBE,1941
|
|
2
2
|
connectonion/address.py,sha256=YOzpMOej-HqJUE6o0i0fG8rB7HM-Iods36s9OD--5ig,10852
|
|
3
3
|
connectonion/agent.py,sha256=BHnP4N0odXCSn9xT0QnJpXj3VV-E_vUtNXJ0M6k3RNs,18889
|
|
4
4
|
connectonion/announce.py,sha256=47Lxe8S4yyTbpsmYUmakU_DehrGvljyldmPfKnAOrFQ,3365
|
|
@@ -9,7 +9,7 @@ connectonion/console.py,sha256=6_J1ItkLJCHDpdJY-tCuw4jMcS09S-a5juZSDSIr1Nc,21254
|
|
|
9
9
|
connectonion/debugger_ui.py,sha256=QMyoZkhGbt-pStHHjpnCBXtfzvfqPW94tXiL07KZiAw,41741
|
|
10
10
|
connectonion/decorators.py,sha256=YFmZMptcchIgNriKFf_vOyacor5i_j6Cy_igTJhdKm4,7141
|
|
11
11
|
connectonion/events.py,sha256=jJOMt1PhRl-ef4R8-WpAq8pUbZ8GKIl0wOB2kJUVyWg,9151
|
|
12
|
-
connectonion/host.py,sha256=
|
|
12
|
+
connectonion/host.py,sha256=eVB907_oFcn2MH-8fRnhR-_-o17S7JjchkggPS5kLVA,19437
|
|
13
13
|
connectonion/interactive_debugger.py,sha256=XHSCGJp9YV6VAZM1gk_AuxKAdBODJQUcLVWaLuTMqv0,16277
|
|
14
14
|
connectonion/llm.py,sha256=IzjlOT6Dj5xIplIymjcaHZ_abwE5wDHEE4pa8zjlEGY,32952
|
|
15
15
|
connectonion/llm_do.py,sha256=YI7kGFKpB6KUEG_CKtP3Bl4IWmRac7TCa9GK5FSV624,12000
|
|
@@ -109,7 +109,7 @@ connectonion/useful_tools/slash_command.py,sha256=VKl7SKLyaxHcHwfE8rgzBCQ2-KQtL0
|
|
|
109
109
|
connectonion/useful_tools/terminal.py,sha256=PtzGHN6vnWROmssi37YOZ5U-d0Z7Fe79bocoKAngoxg,9330
|
|
110
110
|
connectonion/useful_tools/todo_list.py,sha256=wVEt4kt-MczIcP3xvKelfshGHZ6EATpDFzQx0zov8cw,7483
|
|
111
111
|
connectonion/useful_tools/web_fetch.py,sha256=CysJLOdDIkbMVJ12Dj3WgsytLu1-o2wrwNopqA_S1jk,7253
|
|
112
|
-
connectonion-0.5.
|
|
113
|
-
connectonion-0.5.
|
|
114
|
-
connectonion-0.5.
|
|
115
|
-
connectonion-0.5.
|
|
112
|
+
connectonion-0.5.10.dist-info/METADATA,sha256=1xQJXemh__kTUwluT5sYBIG0FasMf2mfdmLd1QszJxg,21903
|
|
113
|
+
connectonion-0.5.10.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
114
|
+
connectonion-0.5.10.dist-info/entry_points.txt,sha256=XDB-kVN7Qgy4DmYTkjQB_O6hZeUND-SqmZbdoQPn6WA,90
|
|
115
|
+
connectonion-0.5.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|