bohr-agent-sdk 0.1.112__tar.gz → 0.1.114__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.
Files changed (89) hide show
  1. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/PKG-INFO +1 -1
  2. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/setup.py +2 -2
  3. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/bohr_agent_sdk.egg-info/PKG-INFO +1 -1
  4. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/adapter/adk/client/calculation_mcp_tool.py +17 -5
  5. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/adapter/adk/utils.py +6 -0
  6. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/calculation_mcp_server.py +30 -1
  7. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/README.md +0 -0
  8. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/pyproject.toml +0 -0
  9. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/setup.cfg +0 -0
  10. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/bohr_agent_sdk.egg-info/SOURCES.txt +0 -0
  11. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/bohr_agent_sdk.egg-info/dependency_links.txt +0 -0
  12. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/bohr_agent_sdk.egg-info/entry_points.txt +0 -0
  13. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/bohr_agent_sdk.egg-info/requires.txt +0 -0
  14. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/bohr_agent_sdk.egg-info/top_level.txt +0 -0
  15. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/__init__.py +0 -0
  16. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/__init__.py +0 -0
  17. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/adapter/adk/__init__.py +0 -0
  18. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/adapter/adk/client/__init__.py +0 -0
  19. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/adapter/adk/storage_artifact_service.py +0 -0
  20. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/adapter/camel/__init__.py +0 -0
  21. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/adapter/camel/client/__init__.py +0 -0
  22. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/adapter/camel/client/calculation_mcp_client.py +0 -0
  23. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/__init__.py +0 -0
  24. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/cli.py +0 -0
  25. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/__init__.py +0 -0
  26. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/calculation/simple.py.template +0 -0
  27. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/device/tescan_device.py.template +0 -0
  28. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/main.py.template +0 -0
  29. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/__init__.py +0 -0
  30. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/__init__.py +0 -0
  31. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/config.py +0 -0
  32. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/constants.py +0 -0
  33. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/debug.py +0 -0
  34. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/files.py +0 -0
  35. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/files_upload.py +0 -0
  36. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/files_user.py +0 -0
  37. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/messages.py +0 -0
  38. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/projects.py +0 -0
  39. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/sessions.py +0 -0
  40. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/utils.py +0 -0
  41. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/api/websocket.py +0 -0
  42. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/config/__init__.py +0 -0
  43. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/config/agent_config.py +0 -0
  44. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/frontend/index.html +0 -0
  45. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/frontend/package.json +0 -0
  46. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/frontend/tsconfig.json +0 -0
  47. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/frontend/tsconfig.node.json +0 -0
  48. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/frontend/ui-static/assets/index-DdAmKhul.js +0 -0
  49. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/frontend/ui-static/assets/index-DfN2raU9.css +0 -0
  50. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/frontend/ui-static/index.html +0 -0
  51. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/frontend/vite.config.ts +0 -0
  52. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/scripts/build_ui.py +0 -0
  53. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/server/__init__.py +0 -0
  54. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/server/app.py +0 -0
  55. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/server/connection.py +0 -0
  56. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/server/file_watcher.py +0 -0
  57. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/server/middleware.py +0 -0
  58. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/server/models.py +0 -0
  59. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/server/session_manager.py +0 -0
  60. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/server/user_files.py +0 -0
  61. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/server/utils.py +0 -0
  62. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/test_download.py +0 -0
  63. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/ui_utils.py +0 -0
  64. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cli/templates/ui/websocket-server.py +0 -0
  65. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/client/__init__.py +0 -0
  66. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/client/mcp_client.py +0 -0
  67. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cloud/__init__.py +0 -0
  68. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cloud/main.py +0 -0
  69. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cloud/mcp.py +0 -0
  70. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/cloud/mqtt.py +0 -0
  71. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/device/__init__.py +0 -0
  72. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/device/device/__init__.py +0 -0
  73. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/device/device/device.py +0 -0
  74. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/device/device/types.py +0 -0
  75. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/device/mqtt_device_twin.py +0 -0
  76. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/__init__.py +0 -0
  77. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/executor/__init__.py +0 -0
  78. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/executor/base_executor.py +0 -0
  79. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/executor/dispatcher_executor.py +0 -0
  80. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/executor/local_executor.py +0 -0
  81. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/preprocessor.py +0 -0
  82. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/storage/__init__.py +0 -0
  83. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/storage/base_storage.py +0 -0
  84. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/storage/bohrium_storage.py +0 -0
  85. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/storage/http_storage.py +0 -0
  86. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/storage/local_storage.py +0 -0
  87. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/storage/oss_storage.py +0 -0
  88. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/src/dp/agent/server/utils.py +0 -0
  89. {bohr_agent_sdk-0.1.112 → bohr_agent_sdk-0.1.114}/tests/test_cli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bohr-agent-sdk
3
- Version: 0.1.112
3
+ Version: 0.1.114
4
4
  Summary: SDK for scientific agents
5
5
  Home-page: https://github.com/dptech-corp/bohr-agent-sdk/
6
6
  Author: DP Technology
@@ -9,7 +9,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
9
9
 
10
10
  setup(
11
11
  name="bohr-agent-sdk",
12
- version="0.1.112",
12
+ version="0.1.114",
13
13
  description="SDK for science agent and mcp tools",
14
14
  long_description=long_description,
15
15
  long_description_content_type="text/markdown",
@@ -76,4 +76,4 @@ setup(
76
76
  "Source": "https://github.com/dptech-corp/bohr-agent-sdk/",
77
77
  # "Documentation": "https://bohr-agent-sdk.readthedocs.io/",
78
78
  },
79
- )
79
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bohr-agent-sdk
3
- Version: 0.1.112
3
+ Version: 0.1.114
4
4
  Summary: SDK for scientific agents
5
5
  Home-page: https://github.com/dptech-corp/bohr-agent-sdk/
6
6
  Author: DP Technology
@@ -105,6 +105,8 @@ class CalculationMCPTool(MCPTool):
105
105
  storage = args["storage"]
106
106
  res = await self.submit_tool.run_async(
107
107
  args=args, tool_context=tool_context, **kwargs)
108
+ if isinstance(res, dict):
109
+ res = types.CallToolResult.model_validate(res)
108
110
  if res.isError:
109
111
  logger.error(res.content[0].text)
110
112
  return res
@@ -125,6 +127,8 @@ class CalculationMCPTool(MCPTool):
125
127
  res = await self.query_tool.run_async(
126
128
  args={"job_id": job_id, "executor": executor},
127
129
  tool_context=tool_context, **kwargs)
130
+ if isinstance(res, dict):
131
+ res = types.CallToolResult.model_validate(res)
128
132
  if res.isError:
129
133
  logger.error(res.content[0].text)
130
134
  else:
@@ -138,6 +142,8 @@ class CalculationMCPTool(MCPTool):
138
142
  res = await self.results_tool.run_async(
139
143
  args={"job_id": job_id, "executor": executor, "storage": storage},
140
144
  tool_context=tool_context, **kwargs)
145
+ if isinstance(res, dict):
146
+ res = types.CallToolResult.model_validate(res)
141
147
  if res.isError:
142
148
  await self.log("error", "Job %s failed: %s" % (
143
149
  job_id, res.content[0].text), tool_context)
@@ -246,13 +252,15 @@ class BackgroundJobWatcher:
246
252
  and part.function_response
247
253
  and part.function_response.id in self.long_running_ids
248
254
  and "result" in part.function_response.response
249
- and not part.function_response.response["result"].isError
250
255
  ):
251
256
  result = part.function_response.response["result"]
252
- results = json.loads(result.content[0].text)
253
- job_id = results["job_id"]
254
- self.long_running_jobs[job_id] = part.function_response
255
- self.status[job_id] = "Running"
257
+ if isinstance(result, dict):
258
+ result = types.CallToolResult.model_validate(result)
259
+ if not result.isError:
260
+ results = json.loads(result.content[0].text)
261
+ job_id = results["job_id"]
262
+ self.long_running_jobs[job_id] = part.function_response
263
+ self.status[job_id] = "Running"
256
264
 
257
265
  async def watch_jobs(self):
258
266
  for job_id in self.status.keys():
@@ -261,6 +269,8 @@ class BackgroundJobWatcher:
261
269
  res = await self.toolset.query_tool.run_async(
262
270
  args={"job_id": job_id, "executor": self.toolset.executor},
263
271
  tool_context=None)
272
+ if isinstance(res, dict):
273
+ res = types.CallToolResult.model_validate(res)
264
274
  if res.isError:
265
275
  logger.error(res.content[0].text)
266
276
  continue
@@ -270,6 +280,8 @@ class BackgroundJobWatcher:
270
280
  args={"job_id": job_id, "executor": self.toolset.executor,
271
281
  "storage": self.toolset.storage},
272
282
  tool_context=None)
283
+ if isinstance(res, dict):
284
+ res = types.CallToolResult.model_validate(res)
273
285
  job_info = getattr(res.content[0], "job_info", {})
274
286
  response = self.long_running_jobs[job_id]
275
287
  if res.isError:
@@ -31,6 +31,8 @@ def update_session_handler(
31
31
  tool_response: dict,
32
32
  ) -> Optional[Dict]:
33
33
  """Update session state with job and artifact information."""
34
+ if isinstance(tool_response, dict):
35
+ tool_response = types.CallToolResult.model_validate(tool_response)
34
36
  if len(tool_response.content) == 0 \
35
37
  or not hasattr(tool_response.content[0], "text"):
36
38
  return None
@@ -83,6 +85,8 @@ def search_error_in_memory_handler(toolset):
83
85
  tool: BaseTool, args: Dict[str, Any], tool_context: ToolContext,
84
86
  tool_response: dict,
85
87
  ) -> Optional[Dict]:
88
+ if isinstance(tool_response, dict):
89
+ tool_response = types.CallToolResult.model_validate(tool_response)
86
90
  if tool_response.isError:
87
91
  err_msg = tool_response.content[0].text
88
92
  if err_msg.startswith("Error executing tool"):
@@ -99,6 +103,8 @@ def search_error_in_memory_handler(toolset):
99
103
  tools = await toolset.get_tools()
100
104
  tool = next(filter(lambda t: t.name == "search_tool_error", tools))
101
105
  res = await tool.run_async(args=args, tool_context=None)
106
+ if isinstance(res, dict):
107
+ res = types.CallToolResult.model_validate(res)
102
108
  result = json.loads(res.content[0].text)
103
109
  logger.info("Search tool error result: %s" % result)
104
110
  if result.get("results") and result[
@@ -17,6 +17,7 @@ from mcp.server.fastmcp.utilities.func_metadata import (
17
17
  ArgModelBase,
18
18
  func_metadata,
19
19
  )
20
+ from mcp.server.sse import SseServerTransport
20
21
  from pydantic import BaseModel, Field, create_model
21
22
  from starlette.responses import JSONResponse
22
23
  from starlette.routing import Route
@@ -267,9 +268,35 @@ class SubmitResult(BaseModel):
267
268
  extra_info: dict | None = None
268
269
 
269
270
 
271
+ def patch_mcp_close_connection():
272
+ _mock_orig_handle_post_message = SseServerTransport.handle_post_message
273
+
274
+ async def _mock_handle_post_message_with_close(self, scope, receive, send):
275
+ async def _send(message):
276
+ if message.get("type") == "http.response.start":
277
+ headers = list(message.get("headers", []))
278
+ headers = [
279
+ (name, value)
280
+ for name, value in headers
281
+ if name.lower() != b"connection"
282
+ ]
283
+ headers.append((b"connection", b"close"))
284
+ message["headers"] = headers
285
+ elif message.get("type") == "http.response.body":
286
+ message["more_body"] = False
287
+ await send(message)
288
+ await _mock_orig_handle_post_message(self, scope, receive, _send)
289
+
290
+ if not getattr(SseServerTransport.handle_post_message,
291
+ "__patched_close__", False):
292
+ SseServerTransport.handle_post_message = \
293
+ _mock_handle_post_message_with_close
294
+ SseServerTransport.handle_post_message.__patched_close__ = True
295
+
296
+
270
297
  class CalculationMCPServer:
271
298
  def __init__(self, *args, preprocess_func=None, fastmcp_mode=False,
272
- **kwargs):
299
+ patch_close_connection=False, **kwargs):
273
300
  """
274
301
  Args:
275
302
  preprocess_func: The preprocess function for all tools
@@ -277,6 +304,8 @@ class CalculationMCPServer:
277
304
  """
278
305
  self.preprocess_func = preprocess_func
279
306
  self.fastmcp_mode = fastmcp_mode
307
+ if patch_close_connection:
308
+ patch_mcp_close_connection()
280
309
  self.mcp = FastMCP(*args, **kwargs)
281
310
  self.fn_metadata_map = {}
282
311