connectonion 0.5.6__py3-none-any.whl → 0.5.7__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 CHANGED
@@ -1,6 +1,6 @@
1
1
  """ConnectOnion - A simple agent framework with behavior tracking."""
2
2
 
3
- __version__ = "0.5.6"
3
+ __version__ = "0.5.7"
4
4
 
5
5
  # Auto-load .env files for the entire framework
6
6
  from dotenv import load_dotenv
connectonion/asgi.py CHANGED
@@ -36,11 +36,20 @@ async def read_body(receive) -> bytes:
36
36
  return body
37
37
 
38
38
 
39
+ # CORS headers for cross-origin requests (e.g., frontend at o.openonion.ai
40
+ # calling deployed agents at *.agents.openonion.ai)
41
+ CORS_HEADERS = [
42
+ [b"access-control-allow-origin", b"*"],
43
+ [b"access-control-allow-methods", b"GET, POST, OPTIONS"],
44
+ [b"access-control-allow-headers", b"authorization, content-type"],
45
+ ]
46
+
47
+
39
48
  async def send_json(send, data: dict, status: int = 200):
40
49
  """Send JSON response via ASGI send."""
41
50
  body = json.dumps(data, default=_json_default).encode()
42
- await send({"type": "http.response.start", "status": status,
43
- "headers": [[b"content-type", b"application/json"]]})
51
+ headers = [[b"content-type", b"application/json"]] + CORS_HEADERS
52
+ await send({"type": "http.response.start", "status": status, "headers": headers})
44
53
  await send({"type": "http.response.body", "body": body})
45
54
 
46
55
 
@@ -56,8 +65,8 @@ async def send_html(send, html: bytes, status: int = 200):
56
65
 
57
66
  async def send_text(send, text: str, status: int = 200):
58
67
  """Send plain text response via ASGI send."""
59
- await send({"type": "http.response.start", "status": status,
60
- "headers": [[b"content-type", b"text/plain; charset=utf-8"]]})
68
+ headers = [[b"content-type", b"text/plain; charset=utf-8"]] + CORS_HEADERS
69
+ await send({"type": "http.response.start", "status": status, "headers": headers})
61
70
  await send({"type": "http.response.body", "body": text.encode()})
62
71
 
63
72
 
@@ -90,6 +99,13 @@ async def handle_http(
90
99
  """
91
100
  method, path = scope["method"], scope["path"]
92
101
 
102
+ # Handle CORS preflight requests
103
+ if method == "OPTIONS":
104
+ headers = CORS_HEADERS + [[b"content-length", b"0"]]
105
+ await send({"type": "http.response.start", "status": 204, "headers": headers})
106
+ await send({"type": "http.response.body", "body": b""})
107
+ return
108
+
93
109
  # Admin endpoints require API key auth
94
110
  if path.startswith("/admin"):
95
111
  headers = dict(scope.get("headers", []))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: connectonion
3
- Version: 0.5.6
3
+ Version: 0.5.7
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,8 +1,8 @@
1
- connectonion/__init__.py,sha256=hL1V7xnh-XjOxREsCJB3CIesGiCwnAzxfoBcZCi9ZPk,1887
1
+ connectonion/__init__.py,sha256=zkprxVlFU1xgEihdSyWnj_Q4L_WqSPkmdYB4HqjV4as,1887
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
5
- connectonion/asgi.py,sha256=rpSScBTA6clbWMdiQlwnlKVcOCQFX7hNVg2JtUhKkO0,8959
5
+ connectonion/asgi.py,sha256=VTMwwEWLq5RYvIufRImMcv-AB5D5pZmM8INaXqwUt4Q,9621
6
6
  connectonion/auto_debug_exception.py,sha256=iA-b5GC40AI4YVXen2UCkDkfHLVZehFPgZrinIxykWI,8147
7
7
  connectonion/connect.py,sha256=dn5dWDkZZpKGW5St-CtAAfTM2-1IOe3luv0vQSA2ogk,5311
8
8
  connectonion/console.py,sha256=6_J1ItkLJCHDpdJY-tCuw4jMcS09S-a5juZSDSIr1Nc,21254
@@ -107,7 +107,7 @@ connectonion/useful_tools/slash_command.py,sha256=VKl7SKLyaxHcHwfE8rgzBCQ2-KQtL0
107
107
  connectonion/useful_tools/terminal.py,sha256=PtzGHN6vnWROmssi37YOZ5U-d0Z7Fe79bocoKAngoxg,9330
108
108
  connectonion/useful_tools/todo_list.py,sha256=wVEt4kt-MczIcP3xvKelfshGHZ6EATpDFzQx0zov8cw,7483
109
109
  connectonion/useful_tools/web_fetch.py,sha256=CysJLOdDIkbMVJ12Dj3WgsytLu1-o2wrwNopqA_S1jk,7253
110
- connectonion-0.5.6.dist-info/METADATA,sha256=uyXKEF5dezmbtaWZ3Hz9gJ-c68c9Hpo45lhaF3XV8L0,21902
111
- connectonion-0.5.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
112
- connectonion-0.5.6.dist-info/entry_points.txt,sha256=XDB-kVN7Qgy4DmYTkjQB_O6hZeUND-SqmZbdoQPn6WA,90
113
- connectonion-0.5.6.dist-info/RECORD,,
110
+ connectonion-0.5.7.dist-info/METADATA,sha256=ARVUGIh4KYImsb6mAc6gWaHSqm-0yHzYt2mXJ-6RY34,21902
111
+ connectonion-0.5.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
112
+ connectonion-0.5.7.dist-info/entry_points.txt,sha256=XDB-kVN7Qgy4DmYTkjQB_O6hZeUND-SqmZbdoQPn6WA,90
113
+ connectonion-0.5.7.dist-info/RECORD,,