@@ -20,35 +20,53 @@ def create(
2020 * ,
2121 agent_id : str ,
2222 name : str ,
23- image : str ,
24- env : dict [str , str ] | None = None ,
25- cpu : str | None = None ,
26- memory_mb : int | None = None ,
27- replicas : int | None = None ,
28- health_check_path : str | None = None ,
23+ template : str | None = None ,
24+ preset : str | None = None ,
25+ image : str | None = None ,
26+ env_public : dict [str , str ] | None = None ,
27+ idle_timeout_secs : int | None = None ,
28+ expose_http : bool | None = None ,
29+ http_port : int | None = None ,
30+ slug : str | None = None ,
31+ inbound_auth : str | None = None ,
32+ shell_access_enabled : bool | None = None ,
33+ shell_auth_policy : str | None = None ,
34+ shell_max_session_minutes : int | None = None ,
2935 ) -> OneclawResponse [Any ]:
3036 """Create a new runtime deployment."""
3137 body : dict [str , Any ] = {
3238 "agent_id" : agent_id ,
3339 "name" : name ,
34- "image" : image ,
3540 }
36- if env is not None :
37- body ["env" ] = env
38- if cpu is not None :
39- body ["cpu" ] = cpu
40- if memory_mb is not None :
41- body ["memory_mb" ] = memory_mb
42- if replicas is not None :
43- body ["replicas" ] = replicas
44- if health_check_path is not None :
45- body ["health_check_path" ] = health_check_path
41+ if template is not None :
42+ body ["template" ] = template
43+ if preset is not None :
44+ body ["preset" ] = preset
45+ if image is not None :
46+ body ["image" ] = image
47+ if env_public is not None :
48+ body ["env_public" ] = env_public
49+ if idle_timeout_secs is not None :
50+ body ["idle_timeout_secs" ] = idle_timeout_secs
51+ if expose_http is not None :
52+ body ["expose_http" ] = expose_http
53+ if http_port is not None :
54+ body ["http_port" ] = http_port
55+ if slug is not None :
56+ body ["slug" ] = slug
57+ if inbound_auth is not None :
58+ body ["inbound_auth" ] = inbound_auth
59+ if shell_access_enabled is not None :
60+ body ["shell_access_enabled" ] = shell_access_enabled
61+ if shell_auth_policy is not None :
62+ body ["shell_auth_policy" ] = shell_auth_policy
63+ if shell_max_session_minutes is not None :
64+ body ["shell_max_session_minutes" ] = shell_max_session_minutes
4665 return self ._http .request ("POST" , "/v1/runtimes" , body = body )
4766
48- def list (self , * , agent_id : str | None = None ) -> OneclawResponse [Any ]:
49- """List runtimes, optionally filtered by agent."""
50- query : dict [str , Any ] | None = {"agent_id" : agent_id } if agent_id else None
51- return self ._http .request ("GET" , "/v1/runtimes" , query = query )
67+ def list (self ) -> OneclawResponse [Any ]:
68+ """List runtimes for the current organization."""
69+ return self ._http .request ("GET" , "/v1/runtimes" )
5270
5371 def get (self , runtime_id : str ) -> OneclawResponse [Any ]:
5472 """Get a runtime by ID."""
@@ -58,27 +76,56 @@ def update(
5876 self ,
5977 runtime_id : str ,
6078 * ,
79+ name : str | None = None ,
6180 image : str | None = None ,
62- env : dict [str , str ] | None = None ,
63- replicas : int | None = None ,
64- status : str | None = None ,
81+ env_public : dict [str , str ] | None = None ,
82+ idle_timeout_secs : int | None = None ,
83+ expose_http : bool | None = None ,
84+ http_port : int | None = None ,
85+ slug : str | None = None ,
86+ inbound_auth : str | None = None ,
87+ shell_access_enabled : bool | None = None ,
88+ shell_auth_policy : str | None = None ,
89+ shell_max_session_minutes : int | None = None ,
6590 ) -> OneclawResponse [Any ]:
6691 """Update a runtime deployment."""
6792 body : dict [str , Any ] = {}
93+ if name is not None :
94+ body ["name" ] = name
6895 if image is not None :
6996 body ["image" ] = image
70- if env is not None :
71- body ["env" ] = env
72- if replicas is not None :
73- body ["replicas" ] = replicas
74- if status is not None :
75- body ["status" ] = status
97+ if env_public is not None :
98+ body ["env_public" ] = env_public
99+ if idle_timeout_secs is not None :
100+ body ["idle_timeout_secs" ] = idle_timeout_secs
101+ if expose_http is not None :
102+ body ["expose_http" ] = expose_http
103+ if http_port is not None :
104+ body ["http_port" ] = http_port
105+ if slug is not None :
106+ body ["slug" ] = slug
107+ if inbound_auth is not None :
108+ body ["inbound_auth" ] = inbound_auth
109+ if shell_access_enabled is not None :
110+ body ["shell_access_enabled" ] = shell_access_enabled
111+ if shell_auth_policy is not None :
112+ body ["shell_auth_policy" ] = shell_auth_policy
113+ if shell_max_session_minutes is not None :
114+ body ["shell_max_session_minutes" ] = shell_max_session_minutes
76115 return self ._http .request ("PATCH" , f"/v1/runtimes/{ runtime_id } " , body = body )
77116
78117 def delete (self , runtime_id : str ) -> OneclawResponse [Any ]:
79118 """Delete a runtime deployment."""
80119 return self ._http .request ("DELETE" , f"/v1/runtimes/{ runtime_id } " )
81120
121+ def start (self , runtime_id : str ) -> OneclawResponse [Any ]:
122+ """Start a stopped runtime."""
123+ return self ._http .request ("POST" , f"/v1/runtimes/{ runtime_id } /start" )
124+
125+ def stop (self , runtime_id : str ) -> OneclawResponse [Any ]:
126+ """Stop a running runtime."""
127+ return self ._http .request ("POST" , f"/v1/runtimes/{ runtime_id } /stop" )
128+
82129 def logs (
83130 self , runtime_id : str , * , since : str | None = None , limit : int | None = None
84131 ) -> OneclawResponse [Any ]:
@@ -90,6 +137,25 @@ def logs(
90137 query ["limit" ] = limit
91138 return self ._http .request ("GET" , f"/v1/runtimes/{ runtime_id } /logs" , query = query or None )
92139
93- def restart (self , runtime_id : str ) -> OneclawResponse [Any ]:
94- """Restart a runtime."""
95- return self ._http .request ("POST" , f"/v1/runtimes/{ runtime_id } /restart" )
140+ def create_shell_session (
141+ self ,
142+ runtime_id : str ,
143+ * ,
144+ password : str | None = None ,
145+ totp_code : str | None = None ,
146+ passkey_credential : dict [str , Any ] | None = None ,
147+ reauth_token : str | None = None ,
148+ ) -> OneclawResponse [Any ]:
149+ """Create an interactive shell WebSocket session (human-only, step-up auth)."""
150+ body : dict [str , Any ] = {}
151+ if password is not None :
152+ body ["password" ] = password
153+ if totp_code is not None :
154+ body ["totp_code" ] = totp_code
155+ if passkey_credential is not None :
156+ body ["passkey_credential" ] = passkey_credential
157+ if reauth_token is not None :
158+ body ["reauth_token" ] = reauth_token
159+ return self ._http .request (
160+ "POST" , f"/v1/runtimes/{ runtime_id } /shell/session" , body = body
161+ )
0 commit comments