mirror of
https://github.com/openai/codex.git
synced 2026-11-20 15:07:25 +00:00
Support remote code-mode hosts in app-server (#35098)
## What changed - Add `--code-mode-host ws://...` and `wss://...` support to `codex app-server`, gated by the `code_mode_host` feature. When omitted, app-server continues to start a local host. - Share one remote WebSocket connection across the process's threads, using the configured HTTP client's proxy and TLS policy and preserving the existing framed host protocol. - Reject invalid host URLs, bound WebSocket frame sizes, close connections cleanly, and return an error when a connection exceeds 1,024 pending delegate calls without disconnecting it. ## Testing - Cover CLI validation, WebSocket protocol execution and shutdown, connection sharing across app-server threads, and delegate-call capacity recovery. GitOrigin-RevId: 715e82d4d9db1e7e2f91b754a777dcab504e2ae4
This commit is contained in:
1 parent
0dfa778dae
commit
f61b51ddd9
28 files changed
+977
-65
No files matched your search
@@ -0,0 +1,51 @@
|
||||
use super::AppServerCodeModeHostArgs;
|
||||
use super::CodeModeHostTransport;
|
||||
use super::parse_websocket_url;
|
||||
use pretty_assertions::assert_eq;
|
||||
use url::Url;
|
||||
|
||||
#[test]
|
||||
fn websocket_host_accepts_local_and_secure_endpoints() {
|
||||
for endpoint in ["ws://127.0.0.1:8765", "wss://example.test/code-mode"] {
|
||||
assert_eq!(
|
||||
parse_websocket_url(endpoint),
|
||||
Ok(Url::parse(endpoint).expect("test endpoint should parse"))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn websocket_host_rejects_invalid_endpoints() {
|
||||
for endpoint in [
|
||||
"http://127.0.0.1:8765",
|
||||
"https://example.test/code-mode",
|
||||
"ws://",
|
||||
"not a websocket",
|
||||
"wss://example.test/code-mode#fragment",
|
||||
] {
|
||||
assert!(
|
||||
parse_websocket_url(endpoint).is_err(),
|
||||
"invalid code-mode host endpoint should be rejected: {endpoint}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn omitted_websocket_host_selects_local_transport() {
|
||||
assert_eq!(
|
||||
CodeModeHostTransport::from(AppServerCodeModeHostArgs::default()),
|
||||
CodeModeHostTransport::Local
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_websocket_host_selects_remote_transport() {
|
||||
let url = Url::parse("wss://example.test/code-mode").expect("test endpoint should parse");
|
||||
|
||||
assert_eq!(
|
||||
CodeModeHostTransport::from(AppServerCodeModeHostArgs {
|
||||
code_mode_host: Some(url.clone()),
|
||||
}),
|
||||
CodeModeHostTransport::WebSocket(url)
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user