@@ -18,7 +18,7 @@ use crate::routing::OwnerCache;
1818use crate :: types:: {
1919 DeleteOptions , DeletionResult , ExecOptions , ExecResult , Health , ListOptions , ResumeOptions ,
2020 SandboxPhase , SandboxRef , SandboxSpec , SandboxTemplateCreateSpec , SandboxTemplateListOptions ,
21- SandboxWorkloadTemplate , WorkspaceRef ,
21+ SandboxWorkloadTemplate , StopExecutionOptions , StopExecutionResult , WorkspaceRef ,
2222} ;
2323use crate :: { WatchEvent , WatchOptions , transport} ;
2424use futures:: { Stream , StreamExt } ;
@@ -399,6 +399,22 @@ impl OpenShellClient {
399399 sandbox_from_response ( response. sandbox )
400400 }
401401
402+ /// Stop only the requested execution in the default workspace.
403+ ///
404+ /// Stale identities fail without stopping a replacement. Unsupported
405+ /// gateways return `Unimplemented`; this never falls back to stopping by name.
406+ /// A replay returns a historical receipt, not the current sandbox state.
407+ pub async fn stop_sandbox_execution (
408+ & self ,
409+ name : & str ,
410+ execution_id : & str ,
411+ opts : StopExecutionOptions ,
412+ ) -> Result < StopExecutionResult > {
413+ self . workspace ( "default" )
414+ . stop_sandbox_execution ( name, execution_id, opts)
415+ . await
416+ }
417+
402418 /// Start a stopped sandbox by name.
403419 pub async fn start_sandbox ( & self , name : & str ) -> Result < SandboxRef > {
404420 let response = self
@@ -1213,6 +1229,39 @@ impl WorkspaceScopedClient {
12131229 sandbox_from_response ( response. sandbox )
12141230 }
12151231
1232+ /// Stop only the requested execution in this workspace.
1233+ ///
1234+ /// The execution identity must come from sandbox status or a verified
1235+ /// supervisor extension JWT. Unsupported gateways never fall back to stop.
1236+ pub async fn stop_sandbox_execution (
1237+ & self ,
1238+ name : & str ,
1239+ execution_id : & str ,
1240+ opts : StopExecutionOptions ,
1241+ ) -> Result < StopExecutionResult > {
1242+ if execution_id. is_empty ( ) {
1243+ return Err ( SdkError :: from_status ( tonic:: Status :: invalid_argument (
1244+ "execution ID must not be empty" ,
1245+ ) ) ) ;
1246+ }
1247+ let response = self
1248+ . client
1249+ . unary ( |mut grpc| {
1250+ let request = proto:: StopSandboxExecutionRequest {
1251+ request_id : opts. request_id . clone ( ) . unwrap_or_default ( ) ,
1252+ name : name. to_string ( ) ,
1253+ execution_id : execution_id. to_string ( ) ,
1254+ workspace_scope : Some ( proto:: workspace_selector ( & self . workspace ) ) ,
1255+ } ;
1256+ async move { grpc. stop_sandbox_execution ( request) . await }
1257+ } )
1258+ . await ?;
1259+ Ok ( StopExecutionResult {
1260+ execution_id : response. execution_id ,
1261+ phase : response. phase . into ( ) ,
1262+ } )
1263+ }
1264+
12161265 /// Start a stopped sandbox by name in this workspace.
12171266 pub async fn start_sandbox ( & self , name : & str ) -> Result < SandboxRef > {
12181267 let response = self
0 commit comments