mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 18:07:47 +08:00
feat(vscodex): add remote Codex collaboration module
This commit is contained in:
@@ -520,6 +520,65 @@ pub(super) fn classify_public_support_route(
|
||||
"aether:ccswitch_usage",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST
|
||||
&& matches!(normalized_path, "/api/vscodex/pair" | "/api/vscodex/pair/")
|
||||
{
|
||||
Some(classified(
|
||||
"public_support",
|
||||
"vscodex",
|
||||
"pairing_exchange",
|
||||
"public:vscodex",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::GET
|
||||
&& matches!(
|
||||
normalized_path,
|
||||
"/api/users/me/vscodex/devices" | "/api/users/me/vscodex/devices/"
|
||||
)
|
||||
{
|
||||
Some(classified(
|
||||
"public_support",
|
||||
"users_me",
|
||||
"vscodex_devices_list",
|
||||
"user:self",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST
|
||||
&& matches!(
|
||||
normalized_path,
|
||||
"/api/users/me/vscodex/pairings" | "/api/users/me/vscodex/pairings/"
|
||||
)
|
||||
{
|
||||
Some(classified(
|
||||
"public_support",
|
||||
"users_me",
|
||||
"vscodex_pairing_create",
|
||||
"user:self",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST
|
||||
&& matches!(
|
||||
normalized_path,
|
||||
"/api/users/me/vscodex/ws-tickets" | "/api/users/me/vscodex/ws-tickets/"
|
||||
)
|
||||
{
|
||||
Some(classified(
|
||||
"public_support",
|
||||
"users_me",
|
||||
"vscodex_ws_ticket_create",
|
||||
"user:self",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::DELETE
|
||||
&& has_single_segment_after_prefix(normalized_path, "/api/users/me/vscodex/devices/")
|
||||
{
|
||||
Some(classified(
|
||||
"public_support",
|
||||
"users_me",
|
||||
"vscodex_device_delete",
|
||||
"user:self",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::GET
|
||||
&& matches!(
|
||||
normalized_path,
|
||||
|
||||
@@ -440,6 +440,26 @@ fn classifies_users_me_routes_as_public_support_route() {
|
||||
"/api/users/me/available-models",
|
||||
"available_models",
|
||||
),
|
||||
(
|
||||
http::Method::GET,
|
||||
"/api/users/me/vscodex/devices",
|
||||
"vscodex_devices_list",
|
||||
),
|
||||
(
|
||||
http::Method::POST,
|
||||
"/api/users/me/vscodex/pairings",
|
||||
"vscodex_pairing_create",
|
||||
),
|
||||
(
|
||||
http::Method::DELETE,
|
||||
"/api/users/me/vscodex/devices/device-1",
|
||||
"vscodex_device_delete",
|
||||
),
|
||||
(
|
||||
http::Method::POST,
|
||||
"/api/users/me/vscodex/ws-tickets",
|
||||
"vscodex_ws_ticket_create",
|
||||
),
|
||||
(
|
||||
http::Method::PUT,
|
||||
"/api/users/me/model-capabilities",
|
||||
@@ -496,6 +516,49 @@ fn classifies_users_me_routes_as_public_support_route() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vscodex_post_routes_buffer_request_body() {
|
||||
let headers = headers(&[]);
|
||||
for path in [
|
||||
"/api/vscodex/pair",
|
||||
"/api/users/me/vscodex/pairings",
|
||||
"/api/users/me/vscodex/ws-tickets",
|
||||
] {
|
||||
let uri: Uri = path.parse().expect("uri should parse");
|
||||
let decision = classify_control_route(&http::Method::POST, &uri, &headers)
|
||||
.expect("route should classify");
|
||||
let context = GatewayPublicRequestContext::from_request_parts(
|
||||
"trace-vscodex",
|
||||
&http::Method::POST,
|
||||
&uri,
|
||||
&headers,
|
||||
Some(decision),
|
||||
);
|
||||
|
||||
assert!(
|
||||
local_proxy_route_requires_buffered_body(&context),
|
||||
"{path} should buffer its JSON body"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classifies_public_vscodex_pairing_exchange() {
|
||||
let headers = headers(&[]);
|
||||
let uri: Uri = "/api/vscodex/pair".parse().expect("uri should parse");
|
||||
let decision =
|
||||
classify_control_route(&http::Method::POST, &uri, &headers).expect("route should classify");
|
||||
|
||||
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
|
||||
assert_eq!(decision.route_family.as_deref(), Some("vscodex"));
|
||||
assert_eq!(decision.route_kind.as_deref(), Some("pairing_exchange"));
|
||||
assert_eq!(
|
||||
decision.auth_endpoint_signature.as_deref(),
|
||||
Some("public:vscodex")
|
||||
);
|
||||
assert!(!decision.is_execution_runtime_candidate());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classifies_ccswitch_usage_as_api_key_public_support_route() {
|
||||
let headers = headers(&[]);
|
||||
|
||||
Reference in New Issue
Block a user