@@ -50,13 +50,8 @@ def drop_boot_lock(self, sandbox_id: str) -> None:
5050 self .boot_locks .pop (sandbox_id , None )
5151
5252 def get_idle_timeout (self , config : dict , provider_id : str ) -> float :
53- sandbox_cfg = config .get ("provider_settings" , {}).get ("sandbox" , {})
54- value = sandbox_cfg .get (f"{ provider_id } _idle_timeout" , 0 )
55- try :
56- timeout = float (value )
57- except (TypeError , ValueError ):
58- return 0.0
59- return max (timeout , 0.0 )
53+ _ = config , provider_id
54+ return 0.0
6055
6156 def build_record_payload (
6257 self ,
@@ -67,8 +62,10 @@ def build_record_payload(
6762 provider_id : str ,
6863 config : dict ,
6964 idle_timeout : float ,
65+ connect_info : dict ,
7066 is_default : bool = False ,
7167 ) -> dict :
68+ _ = config
7269 return {
7370 "sandbox_id" : sandbox_id ,
7471 "sandbox_name" : sandbox_name ,
@@ -78,12 +75,7 @@ def build_record_payload(
7875 "created_by_astrbot" : True ,
7976 "owner_user_id" : session_id ,
8077 "owner_session_id" : session_id ,
81- "connect_info" : {
82- "name" : sandbox_name ,
83- "local" : config .get ("local" , True ),
84- "image" : config .get ("image" ),
85- "os_type" : config .get ("os_type" ),
86- },
78+ "connect_info" : connect_info ,
8779 "is_default" : is_default ,
8880 "idle_timeout" : idle_timeout ,
8981 }
@@ -153,6 +145,7 @@ async def get_or_create_booter(
153145 ) -> ComputerBooter :
154146 provider = self .get_provider (provider_id )
155147 create_config = provider .build_create_config (context , session_id )
148+ idle_timeout = provider .get_idle_timeout (context , session_id )
156149
157150 current_sandbox_id = self .registry .get_current_sandbox_id (session_id )
158151 current_record = (
@@ -186,9 +179,7 @@ async def get_or_create_booter(
186179 self .save_registry ()
187180 self .schedule_idle_cleanup (
188181 current_sandbox_id ,
189- self .get_idle_timeout (
190- context .get_config (umo = session_id ), provider_id
191- ),
182+ idle_timeout ,
192183 )
193184 return booter
194185 self .session_booter .pop (current_sandbox_id , None )
@@ -205,8 +196,9 @@ async def get_or_create_booter(
205196 session_id = session_id ,
206197 provider_id = provider_id ,
207198 config = create_config ,
208- idle_timeout = self .get_idle_timeout (
209- context .get_config (umo = session_id ), provider_id
199+ idle_timeout = idle_timeout ,
200+ connect_info = provider .build_connect_info (
201+ target_sandbox_id , create_config
210202 ),
211203 is_default = True ,
212204 )
@@ -285,7 +277,7 @@ async def get_or_create_booter(
285277 self .save_registry ()
286278 self .schedule_idle_cleanup (
287279 target_sandbox_id ,
288- self . get_idle_timeout ( context . get_config ( umo = session_id ), provider_id ) ,
280+ idle_timeout ,
289281 )
290282 return self .session_booter [target_sandbox_id ]
291283
@@ -298,10 +290,9 @@ async def create_sandbox_uncontrolled(
298290 ) -> dict :
299291 provider = self .get_provider (provider_id )
300292 create_config = provider .build_create_config (context , session_id )
301- config = context .get_config (umo = session_id )
302293 sandbox_id = self .new_sandbox_id (provider_id )
303294 sandbox_name = sandbox_name or sandbox_id
304- idle_timeout = self .get_idle_timeout (config , provider_id )
295+ idle_timeout = provider .get_idle_timeout (context , session_id )
305296 record = self .registry .upsert_sandbox (
306297 ** self .build_record_payload (
307298 sandbox_id = sandbox_id ,
@@ -310,6 +301,7 @@ async def create_sandbox_uncontrolled(
310301 provider_id = provider_id ,
311302 config = create_config ,
312303 idle_timeout = idle_timeout ,
304+ connect_info = provider .build_connect_info (sandbox_name , create_config ),
313305 )
314306 )
315307 try :
@@ -391,6 +383,7 @@ def update_sandbox_config(
391383 def _upsert_new_sandbox_record (
392384 self , context : Context , session_id : str , provider_id : str , create_config : dict
393385 ) -> str :
386+ provider = self .get_provider (provider_id )
394387 sandbox_id = self .new_sandbox_id (provider_id )
395388 self .registry .upsert_sandbox (
396389 ** self .build_record_payload (
@@ -399,9 +392,8 @@ def _upsert_new_sandbox_record(
399392 session_id = session_id ,
400393 provider_id = provider_id ,
401394 config = create_config ,
402- idle_timeout = self .get_idle_timeout (
403- context .get_config (umo = session_id ), provider_id
404- ),
395+ idle_timeout = provider .get_idle_timeout (context , session_id ),
396+ connect_info = provider .build_connect_info (sandbox_id , create_config ),
405397 )
406398 )
407399 self .save_registry ()
0 commit comments