bohr-agent-sdk 0.1.100__py3-none-any.whl → 0.1.102__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.
- {bohr_agent_sdk-0.1.100.dist-info → bohr_agent_sdk-0.1.102.dist-info}/METADATA +6 -2
- bohr_agent_sdk-0.1.102.dist-info/RECORD +80 -0
- dp/agent/adapter/adk/client/calculation_mcp_tool.py +10 -2
- dp/agent/cli/cli.py +126 -25
- dp/agent/cli/templates/__init__.py +1 -0
- dp/agent/cli/templates/calculation/simple.py.template +15 -0
- dp/agent/cli/templates/device/tescan_device.py.template +158 -0
- dp/agent/cli/templates/main.py.template +67 -0
- dp/agent/cli/templates/ui/__init__.py +1 -0
- dp/agent/cli/templates/ui/api/__init__.py +1 -0
- dp/agent/cli/templates/ui/api/config.py +32 -0
- dp/agent/cli/templates/ui/api/constants.py +61 -0
- dp/agent/cli/templates/ui/api/debug.py +257 -0
- dp/agent/cli/templates/ui/api/files.py +469 -0
- dp/agent/cli/templates/ui/api/files_upload.py +115 -0
- dp/agent/cli/templates/ui/api/files_user.py +50 -0
- dp/agent/cli/templates/ui/api/messages.py +161 -0
- dp/agent/cli/templates/ui/api/projects.py +146 -0
- dp/agent/cli/templates/ui/api/sessions.py +93 -0
- dp/agent/cli/templates/ui/api/utils.py +161 -0
- dp/agent/cli/templates/ui/api/websocket.py +184 -0
- dp/agent/cli/templates/ui/config/__init__.py +1 -0
- dp/agent/cli/templates/ui/config/agent_config.py +257 -0
- dp/agent/cli/templates/ui/frontend/index.html +13 -0
- dp/agent/cli/templates/ui/frontend/package.json +46 -0
- dp/agent/cli/templates/ui/frontend/tsconfig.json +26 -0
- dp/agent/cli/templates/ui/frontend/tsconfig.node.json +10 -0
- dp/agent/cli/templates/ui/frontend/ui-static/assets/index-DdAmKhul.js +105 -0
- dp/agent/cli/templates/ui/frontend/ui-static/assets/index-DfN2raU9.css +1 -0
- dp/agent/cli/templates/ui/frontend/ui-static/index.html +14 -0
- dp/agent/cli/templates/ui/frontend/vite.config.ts +37 -0
- dp/agent/cli/templates/ui/scripts/build_ui.py +56 -0
- dp/agent/cli/templates/ui/server/__init__.py +0 -0
- dp/agent/cli/templates/ui/server/app.py +98 -0
- dp/agent/cli/templates/ui/server/connection.py +210 -0
- dp/agent/cli/templates/ui/server/file_watcher.py +85 -0
- dp/agent/cli/templates/ui/server/middleware.py +43 -0
- dp/agent/cli/templates/ui/server/models.py +53 -0
- dp/agent/cli/templates/ui/server/session_manager.py +1158 -0
- dp/agent/cli/templates/ui/server/user_files.py +85 -0
- dp/agent/cli/templates/ui/server/utils.py +50 -0
- dp/agent/cli/templates/ui/test_download.py +98 -0
- dp/agent/cli/templates/ui/ui_utils.py +260 -0
- dp/agent/cli/templates/ui/websocket-server.py +87 -0
- dp/agent/server/storage/http_storage.py +1 -1
- bohr_agent_sdk-0.1.100.dist-info/RECORD +0 -40
- {bohr_agent_sdk-0.1.100.dist-info → bohr_agent_sdk-0.1.102.dist-info}/WHEEL +0 -0
- {bohr_agent_sdk-0.1.100.dist-info → bohr_agent_sdk-0.1.102.dist-info}/entry_points.txt +0 -0
- {bohr_agent_sdk-0.1.100.dist-info → bohr_agent_sdk-0.1.102.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FastAPI middleware definitions
|
|
3
|
+
"""
|
|
4
|
+
from fastapi import Request
|
|
5
|
+
from fastapi.responses import PlainTextResponse
|
|
6
|
+
from starlette.middleware.base import BaseHTTPMiddleware
|
|
7
|
+
from server.utils import get_ak_info_from_request
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RequestLoggingMiddleware(BaseHTTPMiddleware):
|
|
11
|
+
"""Request middleware - for debugging"""
|
|
12
|
+
async def dispatch(self, request: Request, call_next):
|
|
13
|
+
try:
|
|
14
|
+
# Process request info and AK
|
|
15
|
+
access_key, _ = get_ak_info_from_request(request.headers)
|
|
16
|
+
except:
|
|
17
|
+
# Ignore any processing errors
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
response = await call_next(request)
|
|
21
|
+
return response
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class HostValidationMiddleware(BaseHTTPMiddleware):
|
|
25
|
+
"""Host validation middleware"""
|
|
26
|
+
def __init__(self, app, allowed_hosts):
|
|
27
|
+
super().__init__(app)
|
|
28
|
+
self.allowed_hosts = allowed_hosts
|
|
29
|
+
|
|
30
|
+
async def dispatch(self, request: Request, call_next):
|
|
31
|
+
host = request.headers.get("host", "").split(":")[0]
|
|
32
|
+
# If allowed list contains "*", allow all hosts
|
|
33
|
+
if "*" in self.allowed_hosts:
|
|
34
|
+
response = await call_next(request)
|
|
35
|
+
return response
|
|
36
|
+
# Otherwise check if host is in allowed list
|
|
37
|
+
if host and host not in self.allowed_hosts:
|
|
38
|
+
return PlainTextResponse(
|
|
39
|
+
content=f"Host '{host}' is not allowed",
|
|
40
|
+
status_code=403
|
|
41
|
+
)
|
|
42
|
+
response = await call_next(request)
|
|
43
|
+
return response
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Data model definitions
|
|
3
|
+
"""
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from typing import Optional, List
|
|
7
|
+
import uuid
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class Message:
|
|
12
|
+
"""Message data model"""
|
|
13
|
+
id: str
|
|
14
|
+
role: str # 'user' or 'assistant' or 'tool'
|
|
15
|
+
content: str
|
|
16
|
+
timestamp: datetime = field(default_factory=datetime.now)
|
|
17
|
+
tool_name: Optional[str] = None
|
|
18
|
+
tool_status: Optional[str] = None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class Session:
|
|
23
|
+
"""Session data model"""
|
|
24
|
+
id: str
|
|
25
|
+
title: str = "New Session"
|
|
26
|
+
messages: List[Message] = field(default_factory=list)
|
|
27
|
+
created_at: datetime = field(default_factory=datetime.now)
|
|
28
|
+
last_message_at: datetime = field(default_factory=datetime.now)
|
|
29
|
+
is_modified: bool = False # Mark if session has been modified
|
|
30
|
+
last_saved_at: Optional[datetime] = None # Last save time
|
|
31
|
+
|
|
32
|
+
def add_message(self, role: str, content: str, tool_name: Optional[str] = None, tool_status: Optional[str] = None):
|
|
33
|
+
"""Add message to session"""
|
|
34
|
+
message = Message(
|
|
35
|
+
id=str(uuid.uuid4()),
|
|
36
|
+
role=role,
|
|
37
|
+
content=content,
|
|
38
|
+
tool_name=tool_name,
|
|
39
|
+
tool_status=tool_status
|
|
40
|
+
)
|
|
41
|
+
self.messages.append(message)
|
|
42
|
+
self.last_message_at = datetime.now()
|
|
43
|
+
self.is_modified = True # Mark as modified
|
|
44
|
+
|
|
45
|
+
if self.title == "New Session" and role == "user" and len(self.messages) <= 2:
|
|
46
|
+
self.title = content[:30] + "..." if len(content) > 30 else content
|
|
47
|
+
|
|
48
|
+
return message
|
|
49
|
+
|
|
50
|
+
def mark_saved(self):
|
|
51
|
+
"""Mark session as saved"""
|
|
52
|
+
self.is_modified = False
|
|
53
|
+
self.last_saved_at = datetime.now()
|