feat(clients): sandbox: data plane (JWT proxy, CDP WebSocket), operations, SDK chunk shapes

Data plane per the computer use quickstart and SDK 2.6.0 source: signJwt
minted JWT, /cdp /tabs /cdp_ws_endpoint over HTTP with routing headers, CDP
over the live WsClient with capped reconnect. Operations methods wrapped,
input/output chunk shapes settled from the SDK, ComputerUse moved off execute.
Execution paths remain verified by Discovery, docs and SDK only.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 05:30:44 +02:00
co-authored by Claude Sonnet 5.5
parent 29d775a923
commit 1c3fbe1899
33 changed files with 3031 additions and 185 deletions
@@ -39,6 +39,44 @@ int main() {
bad("/agent/sandbox/files", "{\"name\":\"" + sandbox + "\",\"op\":\"zap\"}", "unknown file op");
bad("/agent/sandbox/snapshot", "{\"name\":\"" + sandbox + "\",\"display_name\":\"s\",\"post_action\":\"STOP\"}", "bad post action");
// Data plane, CDP, stream, operations, resources, templates.
const std::string op = sandbox + "/operations/1";
bad("/agent/sandbox/dataplane", "{\"name\":\"" + sandbox + "\",\"action\":\"fly\"}", "unknown data plane action");
bad("/agent/sandbox/dataplane", "{\"name\":\"" + engine + "\",\"action\":\"health\"}", "engine used as sandbox name");
bad("/agent/sandbox/dataplane", "{\"name\":\"" + sandbox + "\",\"action\":\"activate\",\"tab_id\":\"../x\"}", "tab id with dots");
bad("/agent/sandbox/dataplane", "{\"name\":\"" + sandbox + "\",\"action\":\"activate\"}", "missing tab id");
bad("/agent/sandbox/dataplane", "{\"name\":\"" + sandbox + "\",\"action\":\"command\",\"command\":\"nope\"}", "command without a domain");
bad("/agent/sandbox/dataplane", "{\"name\":\"" + sandbox + "\",\"action\":\"command\",\"command\":\"Page.reload\",\"params\":\"[1]\"}", "params that are not an object");
bad("/agent/sandbox/cdp", "{\"name\":\"" + sandbox + "\",\"method\":\"\"}", "empty CDP method");
bad("/agent/sandbox/cdp", "{\"name\":\"" + sandbox + "\",\"method\":\"Page.a.b\"}", "CDP method with two dots");
bad("/agent/sandbox/cdp", "{\"name\":\"x\",\"method\":\"Page.reload\"}", "bad sandbox name for CDP");
bad("/agent/sandbox/cdp", "{\"name\":\"" + sandbox + "\",\"method\":\"Page.reload\",\"params\":\"{bad\"}", "params that are not JSON");
bad("/agent/sandbox/stream", "{\"name\":\"" + sandbox + "\",\"mode\":\"vm\",\"input\":\"x\"}", "unknown stream mode");
bad("/agent/sandbox/stream", "{\"name\":\"" + sandbox + "\",\"mode\":\"shell\",\"input\":\"\"}", "empty stream command");
bad("/agent/sandbox/stream", "{\"name\":\"" + sandbox + "\",\"mode\":\"code\",\"input\":\"\"}", "empty stream code");
bad("/agent/sandbox/operations", "{\"name\":\"" + op + "\",\"op\":\"delete\"}", "delete is not a POST op");
bad("/agent/sandbox/operations", "{\"name\":\"" + sandbox + "\",\"op\":\"get\"}", "sandbox name used as operation name");
bad("/agent/sandbox/operations", "{\"name\":\"" + op + "\",\"op\":\"wait\",\"timeout\":\"0\"}", "wait timeout under the floor");
bad("/agent/sandbox/operations", "{\"name\":\"" + op + "\",\"op\":\"wait\",\"timeout\":\"121\"}", "wait timeout over the cap");
bad("/agent/sandbox/operations", "{\"name\":\"" + engine + "\",\"op\":\"list\"}", "engine used as operations parent");
bad("/agent/sandbox/operations", "{\"name\":\"" + sandbox + "\",\"op\":\"list\",\"page_size\":\"101\"}", "page size over the cap");
bad("/agent/sandbox/resource", "{\"name\":\"" + sandbox + "\",\"kind\":\"template\"}", "sandbox name as template");
bad("/agent/sandbox/resource", "{\"name\":\"" + sandbox + "\",\"kind\":\"disk\"}", "unknown resource kind");
bad("/agent/sandbox/template", "{\"engine\":\"" + engine + "\",\"display_name\":\"t\",\"category\":\"gpu\"}", "unknown template category");
bad("/agent/sandbox/template", "{\"engine\":\"" + engine + "\",\"display_name\":\"t\"}", "template without a category or image");
bad("/agent/sandbox/template", "{\"engine\":\"x\",\"display_name\":\"t\",\"category\":\"shell\"}", "bad engine for template");
check(f.client->request(molo::example::fw::Method::Delete, "/agent/sandbox/operation?name=bad").status == 422,
"operation delete with a bad name is 422");
check(f.client->request(molo::example::fw::Method::Delete, "/agent/sandbox/resource?kind=disk&name=x").status == 422,
"resource delete with an unknown kind is 422");
check(f.client->request(molo::example::fw::Method::Delete, "/agent/sandbox/resource?kind=snapshot&name=bad").status == 422,
"resource delete with a bad name is 422");
check(f.client->get("/agent/sandbox/dataplane").status == 405, "GET on dataplane is 405");
check(f.client->get("/agent/sandbox/cdp").status == 405, "GET on cdp is 405");
check(f.client->get("/agent/sandbox/stream").status == 405, "GET on stream is 405");
check(f.client->get("/agent/sandbox/operations").status == 405, "GET on operations is 405");
check(f.client->post("/agent/sandbox/operation").status == 405, "POST on operation delete is 405");
// Limit cases: the caps hold at the route.
std::string huge_cmd(8193, 'a');
bad("/agent/sandbox/shell", "{\"name\":\"" + sandbox + "\",\"command\":\"" + huge_cmd + "\"}", "command over 8192 bytes");