mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Add app-server background terminal process APIs (#26041)
## Summary Codex Apps needs app-server as the source of truth for chat-started background terminals instead of guessing from local process trees. This PR adds experimental v2 APIs to list and terminate background terminals for a loaded thread using app-server process ids, so clients can manage background terminals without local PID discovery. ## Changes - `thread/backgroundTerminals/list` returns paginated background terminal records with `itemId`, app-server `processId`, `command`, `cwd`, nullable `osPid`, nullable `cpuPercent`, and nullable `rssKb`. - `thread/backgroundTerminals/terminate` terminates one running background terminal by app-server `processId` and returns whether a process was terminated. - Background terminal list and terminate operations use unified-exec process manager state as their source of truth.
This commit is contained in:
1 parent
2704ecea9a
commit
a1a8807e9d
16 files changed
+773
-36
No files matched your search
@@ -574,6 +574,18 @@ client_request_definitions! {
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadBackgroundTerminalsCleanResponse,
|
||||
},
|
||||
#[experimental("thread/backgroundTerminals/list")]
|
||||
ThreadBackgroundTerminalsList => "thread/backgroundTerminals/list" {
|
||||
params: v2::ThreadBackgroundTerminalsListParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadBackgroundTerminalsListResponse,
|
||||
},
|
||||
#[experimental("thread/backgroundTerminals/terminate")]
|
||||
ThreadBackgroundTerminalsTerminate => "thread/backgroundTerminals/terminate" {
|
||||
params: v2::ThreadBackgroundTerminalsTerminateParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
response: v2::ThreadBackgroundTerminalsTerminateResponse,
|
||||
},
|
||||
ThreadRollback => "thread/rollback" {
|
||||
params: v2::ThreadRollbackParams,
|
||||
serialization: thread_id(params.thread_id),
|
||||
@@ -2936,6 +2948,54 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_background_terminals_list() -> Result<()> {
|
||||
let request = ClientRequest::ThreadBackgroundTerminalsList {
|
||||
request_id: RequestId::Integer(8),
|
||||
params: v2::ThreadBackgroundTerminalsListParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
cursor: None,
|
||||
limit: None,
|
||||
},
|
||||
};
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "thread/backgroundTerminals/list",
|
||||
"id": 8,
|
||||
"params": {
|
||||
"threadId": "thr_123",
|
||||
"cursor": null,
|
||||
"limit": null
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&request)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_background_terminals_terminate() -> Result<()> {
|
||||
let request = ClientRequest::ThreadBackgroundTerminalsTerminate {
|
||||
request_id: RequestId::Integer(8),
|
||||
params: v2::ThreadBackgroundTerminalsTerminateParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
process_id: "42".to_string(),
|
||||
},
|
||||
};
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "thread/backgroundTerminals/terminate",
|
||||
"id": 8,
|
||||
"params": {
|
||||
"threadId": "thr_123",
|
||||
"processId": "42"
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&request)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_realtime_start() -> Result<()> {
|
||||
let request = ClientRequest::ThreadRealtimeStart {
|
||||
|
||||
Reference in new issue
Block a user