2323
2424
2525# Configuration defaults - can be overridden via environment variables
26- DEFAULT_SERVER = os .getenv ("OPENCLAW_SERVER" , "http://localhost:8080" )
26+ DEFAULT_SERVER = os .getenv ("OPEN_SANDBOX_SERVER" , "http://localhost:8080" )
27+ DEFAULT_API_KEY = os .getenv ("OPEN_SANDBOX_API_KEY" , "" )
2728DEFAULT_IMAGE = os .getenv ("OPENCLAW_IMAGE" , "ghcr.io/openclaw/openclaw:latest" )
2829DEFAULT_TIMEOUT = int (os .getenv ("OPENCLAW_TIMEOUT" , "3600" ))
2930DEFAULT_TOKEN = os .getenv ("OPENCLAW_TOKEN" , "dummy-token-for-sandbox" )
@@ -64,12 +65,14 @@ def check_openclaw(sbx: SandboxSync, port: int = DEFAULT_PORT) -> bool:
6465
6566def main () -> None :
6667 server = DEFAULT_SERVER
68+ api_key = DEFAULT_API_KEY
6769 image = DEFAULT_IMAGE
6870 timeout_seconds = DEFAULT_TIMEOUT
6971 token = os .getenv ("OPENCLAW_GATEWAY_TOKEN" , DEFAULT_TOKEN )
7072 port = DEFAULT_PORT
7173
7274 print (f"Creating openclaw sandbox with image={ image } on OpenSandbox server { server } ..." )
75+ print (f" API Key: { api_key [:16 ]} ..." if len (api_key ) > 16 else f" API Key: { api_key } " )
7376 print (f" Token: { token [:16 ]} ..." if len (token ) > 16 else f" Token: { token } " )
7477 print (f" Port: { port } " )
7578 print (f" Timeout: { timeout_seconds } s" )
@@ -78,8 +81,8 @@ def main() -> None:
7881 image = image ,
7982 timeout = timedelta (seconds = timeout_seconds ),
8083 metadata = {"example" : "openclaw" },
81- entrypoint = [f "node dist/index.js gateway --bind=lan --port { port } --allow-unconfigured --verbose" ],
82- connection_config = ConnectionConfigSync (domain = server ),
84+ entrypoint = ["node" , " dist/index.js" , " gateway" , " --bind=lan" , " --port" , str ( port ), " --allow-unconfigured" , " --verbose" ],
85+ connection_config = ConnectionConfigSync (domain = server , api_key = api_key ),
8386 health_check = lambda sbx : check_openclaw (sbx , port ),
8487 # env for openclaw
8588 env = {
@@ -101,4 +104,4 @@ def main() -> None:
101104 print (f"Openclaw started finished. Please refer to { endpoint .endpoint } " )
102105
103106if __name__ == "__main__" :
104- main ()
107+ main ()
0 commit comments