bohr-agent-sdk 0.1.118__py3-none-any.whl → 0.1.119__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bohr-agent-sdk
3
- Version: 0.1.118
3
+ Version: 0.1.119
4
4
  Summary: SDK for scientific agents
5
5
  Home-page: https://github.com/dptech-corp/bohr-agent-sdk/
6
6
  Author: DP Technology
@@ -17,7 +17,7 @@ dp/agent/cli/templates/device/tescan_device.py.template,sha256=c7RIwWhfwp5WiPy1S
17
17
  dp/agent/cli/templates/ui/__init__.py,sha256=QgYZneX7gKyajZIEvbHIEMD3av3bKj64E_eeDPBeuvY,14
18
18
  dp/agent/cli/templates/ui/test_download.py,sha256=RzZ59pVd-4fYIbUbW6ZO1b1Twbycu5G6yb5yLFuT0oI,3002
19
19
  dp/agent/cli/templates/ui/ui_utils.py,sha256=OMgQxZ-UvIJB_a58YBMypQKTI7N9B3AQBOR7kOTudRE,9774
20
- dp/agent/cli/templates/ui/websocket-server.py,sha256=YLVnXyBelrZLo9EcU-17_qts4-UVscMM8-cX08X6XYY,2809
20
+ dp/agent/cli/templates/ui/websocket-server.py,sha256=vhLsDuhQFxqp9RL7lWq3M8CP196VDZuoI3y_5YPqXQA,2968
21
21
  dp/agent/cli/templates/ui/api/__init__.py,sha256=eq1djuBJYvWlGTgxXvT9A386Eu21FNCcB7gV2lU46dU,8
22
22
  dp/agent/cli/templates/ui/api/config.py,sha256=ZhHApcXDrmO1JjI-Ok09ETYB-BVis390ZrMRt140DhQ,1018
23
23
  dp/agent/cli/templates/ui/api/constants.py,sha256=mHY81zf4ksfKEOsSiVsWD_A_KcQ6wveLvAImCay_kVM,1391
@@ -47,7 +47,7 @@ dp/agent/cli/templates/ui/server/connection.py,sha256=DVlhx49gMjKVPxOpi7spAZiHZA
47
47
  dp/agent/cli/templates/ui/server/file_watcher.py,sha256=t0e7IMgf4E1y0CxeboCqsVeZPBo1CGSw_qoO8wG6Wy4,2923
48
48
  dp/agent/cli/templates/ui/server/middleware.py,sha256=bNR5aFqKjxv2einQ0e26aq6tiUW4SMses3IHkrmHDCk,1474
49
49
  dp/agent/cli/templates/ui/server/models.py,sha256=obfMkFFB9qZZXDdwoC25u3tBlUC6Rz7sjeyuh7a_UWk,1680
50
- dp/agent/cli/templates/ui/server/session_manager.py,sha256=ZbNHGCFvswa-LKWn6c6RMHWDdfeOvY5L6A8CfrsF0OE,46536
50
+ dp/agent/cli/templates/ui/server/session_manager.py,sha256=GviOjYZtdbd4Cpdxc0zfb1NV38uBvyJnzgd9uUusb9k,46528
51
51
  dp/agent/cli/templates/ui/server/user_files.py,sha256=khkiyY2UOOysHqO6JgCPUDqtrInp83G1M62i3Lj-0aY,2995
52
52
  dp/agent/cli/templates/ui/server/utils.py,sha256=f4NfwFBq_RdZyFn_KCW6ZThYW8TvQyVruK7PJZ-DA80,1530
53
53
  dp/agent/client/__init__.py,sha256=yu7HYZwAkD7g5dL9JttLkGmspBcyOf-6OoCjci4oPDA,59
@@ -62,7 +62,7 @@ dp/agent/device/device/__init__.py,sha256=w7_1S16S1vWUq0RGl0GFgjq2vFkc5oNvy8cQTn
62
62
  dp/agent/device/device/device.py,sha256=9ZRIJth-4qMO-i-u_b_cO3d6a4eTbTQjPaxFsV_zEkc,9643
63
63
  dp/agent/device/device/types.py,sha256=JuxB-hjf1CjjvfBxCLwRAXVFlYS-nPEdiJpBWLFVCzo,1924
64
64
  dp/agent/server/__init__.py,sha256=rckaYd8pbYyB4ENEhgjXKeGMXjdnrgcJpdM1gu5u1Wc,508
65
- dp/agent/server/calculation_mcp_server.py,sha256=D28eEwcaOGRHq3Vwgm-eJINRVU5vz46HDTvmWnouCKQ,19045
65
+ dp/agent/server/calculation_mcp_server.py,sha256=Nq1lv-H1E8J1yNz85TCbl1GtSQXQGZfAIB1qKajZcNY,19664
66
66
  dp/agent/server/preprocessor.py,sha256=XUWu7QOwo_sIDMYS2b1OTrM33EXEVH_73vk-ju1Ok8A,1264
67
67
  dp/agent/server/utils.py,sha256=cIKaAg8UaP5yMwvIVTgUVBjy-B3S16bEdnucUf4UDIM,2055
68
68
  dp/agent/server/executor/__init__.py,sha256=s95M5qKQk39Yi9qaVJZhk_nfj54quSf7EDghR3OCFUA,248
@@ -75,8 +75,8 @@ dp/agent/server/storage/bohrium_storage.py,sha256=EsKX4dWWvZTn2TEhZv4zsvihfDK0mm
75
75
  dp/agent/server/storage/http_storage.py,sha256=KiySq7g9-iJr12XQCKKyJLn8wJoDnSRpQAR5_qPJ1ZU,1471
76
76
  dp/agent/server/storage/local_storage.py,sha256=t1wfjByjXew9ws3PuUxWxmZQ0-Wt1a6t4wmj3fW62GI,1352
77
77
  dp/agent/server/storage/oss_storage.py,sha256=pgjmi7Gir3Y5wkMDCvU4fvSls15fXT7Ax-h9MYHFPK0,3359
78
- bohr_agent_sdk-0.1.118.dist-info/METADATA,sha256=vNyEqSDKjWct5yfQIMwFYFz45Ofw71ODoceNhmAk7Vw,11070
79
- bohr_agent_sdk-0.1.118.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
80
- bohr_agent_sdk-0.1.118.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
81
- bohr_agent_sdk-0.1.118.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
82
- bohr_agent_sdk-0.1.118.dist-info/RECORD,,
78
+ bohr_agent_sdk-0.1.119.dist-info/METADATA,sha256=oG4bst9eor1ytVutI5UGppqY8aJ-C9c12jKOGBoHh2g,11070
79
+ bohr_agent_sdk-0.1.119.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
80
+ bohr_agent_sdk-0.1.119.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
81
+ bohr_agent_sdk-0.1.119.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
82
+ bohr_agent_sdk-0.1.119.dist-info/RECORD,,
@@ -632,7 +632,7 @@ class SessionManager:
632
632
  ):
633
633
  """Process message stream - using ADK native event handling"""
634
634
  streaming_text = "" # Accumulate streaming text
635
-
635
+
636
636
  # Run Runner
637
637
  async for event in runner.run_async(
638
638
  new_message=content,
@@ -48,11 +48,13 @@ if __name__ == "__main__":
48
48
 
49
49
  # uvicorn 始终监听 0.0.0.0 以支持所有配置的主机
50
50
  uvicorn.run(
51
- app,
52
- host="0.0.0.0",
51
+ app,
52
+ host="0.0.0.0",
53
53
  port=port,
54
54
  log_level="info", # 使用 info 级别,过滤掉 warning
55
55
  access_log=False, # 禁用访问日志,减少噪音
56
+ ws_ping_interval=20, # Send WebSocket ping every 20s to keep connection alive
57
+ ws_ping_timeout=30, # Disconnect if no pong received within 30s
56
58
  # 添加自定义的日志配置
57
59
  log_config={
58
60
  "version": 1,
@@ -26,6 +26,7 @@ from .executor import executor_dict
26
26
  from .storage import storage_dict
27
27
  from .utils import get_logger, JobResult, Tool
28
28
  logger = get_logger(__name__)
29
+ CALCULATION_MCP_WORKDIR = os.getenv("CALCULATION_MCP_WORKDIR", os.getcwd())
29
30
 
30
31
 
31
32
  def parse_uri(uri):
@@ -81,7 +82,8 @@ def query_job_status(job_id: str, executor: Optional[dict] = None
81
82
  status (str): One of "Running", "Succeeded" or "Failed"
82
83
  """
83
84
  trace_id, exec_id = job_id.split("/")
84
- with set_directory(trace_id):
85
+ workdir = os.path.join(CALCULATION_MCP_WORKDIR, trace_id)
86
+ with set_directory(workdir):
85
87
  executor = load_job_info()["executor"] or executor
86
88
  _, executor = init_executor(executor)
87
89
  status = executor.query_status(exec_id)
@@ -96,7 +98,8 @@ def terminate_job(job_id: str, executor: Optional[dict] = None):
96
98
  job_id (str): The ID of the calculation job
97
99
  """
98
100
  trace_id, exec_id = job_id.split("/")
99
- with set_directory(trace_id):
101
+ workdir = os.path.join(CALCULATION_MCP_WORKDIR, trace_id)
102
+ with set_directory(workdir):
100
103
  executor = load_job_info()["executor"] or executor
101
104
  _, executor = init_executor(executor)
102
105
  executor.terminate(exec_id)
@@ -130,13 +133,15 @@ def handle_input_artifacts(fn, kwargs, storage):
130
133
  kwargs.get(name) is not None):
131
134
  uris = kwargs[name]
132
135
  new_paths = []
133
- for uri in uris:
136
+ for i, uri in enumerate(uris):
134
137
  scheme, key = parse_uri(uri)
135
138
  if scheme == storage_type:
136
139
  s = storage
137
140
  else:
138
141
  s = storage_dict[scheme]()
139
- path = s.download(key, "inputs/%s" % name)
142
+ dest_dir = Path("inputs") / name / f"item_{i:03d}"
143
+ dest_dir.mkdir(parents=True, exist_ok=True)
144
+ path = s.download(key, str(dest_dir))
140
145
  new_paths.append(Path(path))
141
146
  logger.info("Artifact %s downloaded to %s" % (
142
147
  uri, path))
@@ -172,13 +177,15 @@ def handle_input_artifacts(fn, kwargs, storage):
172
177
  new_paths_dict = {}
173
178
  for key_name, uris in uris_dict.items():
174
179
  new_paths = []
175
- for uri in uris:
180
+ for i, uri in enumerate(uris):
176
181
  scheme, key = parse_uri(uri)
177
182
  if scheme == storage_type:
178
183
  s = storage
179
184
  else:
180
185
  s = storage_dict[scheme]()
181
- path = s.download(key, f"inputs/{name}/{key_name}")
186
+ dest_dir = Path("inputs") / name / key_name / f"item_{i:03d}"
187
+ dest_dir.mkdir(parents=True, exist_ok=True)
188
+ path = s.download(key, str(dest_dir))
182
189
  new_paths.append(Path(path))
183
190
  logger.info("Artifact %s (key=%s) downloaded to %s" % (
184
191
  uri, key_name, path))
@@ -237,7 +244,8 @@ def get_job_results(job_id: str, executor: Optional[dict] = None,
237
244
  results (Any): results of the calculation job
238
245
  """
239
246
  trace_id, exec_id = job_id.split("/")
240
- with set_directory(trace_id):
247
+ workdir = os.path.join(CALCULATION_MCP_WORKDIR, trace_id)
248
+ with set_directory(workdir):
241
249
  job_info = load_job_info()
242
250
  executor = job_info["executor"] or executor
243
251
  storage = job_info["storage"] or storage
@@ -386,7 +394,7 @@ class CalculationMCPServer:
386
394
  if create_workdir is False:
387
395
  workdir = "."
388
396
  else:
389
- workdir = trace_id
397
+ workdir = os.path.join(CALCULATION_MCP_WORKDIR, trace_id)
390
398
  with set_directory(workdir):
391
399
  if preprocess_func is not None:
392
400
  executor, storage, kwargs = preprocess_func(
@@ -431,7 +439,7 @@ class CalculationMCPServer:
431
439
  and executor_type == "local"):
432
440
  workdir = "."
433
441
  else:
434
- workdir = trace_id
442
+ workdir = os.path.join(CALCULATION_MCP_WORKDIR, trace_id)
435
443
  with set_directory(workdir):
436
444
  kwargs, input_artifacts = handle_input_artifacts(
437
445
  fn, kwargs, storage)