@@ -54,9 +54,9 @@ def _save_cua_registry() -> None:
5454 sandbox_manager .save_registry ()
5555
5656
57- def _get_cua_idle_timeout (config : dict ) -> float :
57+ def _get_cua_idle_timeout (context : Context , session_id : str ) -> float :
5858 _sync_sandbox_manager_refs ()
59- return sandbox_manager .get_idle_timeout (config , "cua" )
59+ return sandbox_manager .providers [ "cua" ]. get_idle_timeout (context , session_id )
6060
6161
6262def _clear_cua_idle_state (sandbox_id : str ) -> None :
@@ -176,39 +176,6 @@ async def _boot_managed_cua_sandbox_hook(
176176_sync_sandbox_manager_refs ()
177177
178178
179- def _new_managed_cua_sandbox_id () -> str :
180- return f"cua-{ uuid .uuid4 ().hex [:12 ]} "
181-
182-
183- def _build_cua_sandbox_record_payload (
184- * ,
185- sandbox_id : str ,
186- sandbox_name : str ,
187- session_id : str ,
188- cua_kwargs : dict ,
189- idle_timeout : float ,
190- is_default : bool = False ,
191- ) -> dict :
192- return {
193- "sandbox_id" : sandbox_id ,
194- "sandbox_name" : sandbox_name ,
195- "booter_type" : "cua" ,
196- "provider" : "cua" ,
197- "managed" : True ,
198- "created_by_astrbot" : True ,
199- "owner_user_id" : session_id ,
200- "owner_session_id" : session_id ,
201- "connect_info" : {
202- "name" : sandbox_name ,
203- "local" : cua_kwargs .get ("local" , True ),
204- "image" : cua_kwargs .get ("image" ),
205- "os_type" : cua_kwargs .get ("os_type" ),
206- },
207- "is_default" : is_default ,
208- "idle_timeout" : idle_timeout ,
209- }
210-
211-
212179async def _get_or_create_cua_booter (
213180 context : Context , session_id : str , sandbox_cfg : dict
214181) -> ComputerBooter :
@@ -471,7 +438,10 @@ async def get_cua_observer_booter(context: Context, session_id: str) -> Computer
471438 current_sandbox_id = getattr (booter , "sandbox_id" , current_sandbox_id )
472439 cua_registry .touch_sandbox (current_sandbox_id )
473440 _save_cua_registry ()
474- _schedule_cua_idle_cleanup (current_sandbox_id , _get_cua_idle_timeout (config ))
441+ _schedule_cua_idle_cleanup (
442+ current_sandbox_id ,
443+ _get_cua_idle_timeout (context , session_id ),
444+ )
475445 return booter
476446
477447
0 commit comments