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:
@@ -31,6 +31,25 @@ int main() {
|
||||
{"/agent/sandbox/computer",
|
||||
"{\"name\":\"" + sandbox + "\",\"action\":\"navigate\",\"url\":\"https://example.com\"}"},
|
||||
{"/agent/sandbox/files", "{\"name\":\"" + sandbox + "\",\"op\":\"list\"}"},
|
||||
{"/agent/sandbox/dataplane", "{\"name\":\"" + sandbox + "\",\"action\":\"health\"}"},
|
||||
{"/agent/sandbox/dataplane",
|
||||
"{\"name\":\"" + sandbox + "\",\"action\":\"command\",\"command\":\"Page.reload\"}"},
|
||||
{"/agent/sandbox/cdp", "{\"name\":\"" + sandbox + "\",\"method\":\"Page.reload\"}"},
|
||||
{"/agent/sandbox/stream", "{\"name\":\"" + sandbox + "\",\"mode\":\"shell\",\"input\":\"echo hi\"}"},
|
||||
{"/agent/sandbox/stream", "{\"name\":\"" + sandbox + "\",\"mode\":\"code\",\"input\":\"print(1)\"}"},
|
||||
{"/agent/sandbox/operations",
|
||||
"{\"name\":\"" + sandbox + "/operations/1\",\"op\":\"get\"}"},
|
||||
{"/agent/sandbox/operations",
|
||||
"{\"name\":\"" + sandbox + "/operations/1\",\"op\":\"wait\",\"timeout\":\"5\"}"},
|
||||
{"/agent/sandbox/operations", "{\"name\":\"" + sandbox + "\",\"op\":\"list\"}"},
|
||||
{"/agent/sandbox/operations",
|
||||
"{\"name\":\"" + sandbox + "/operations/1\",\"op\":\"cancel\"}"},
|
||||
{"/agent/sandbox/resource",
|
||||
"{\"name\":\"" + engine + "/sandboxEnvironmentTemplates/7\",\"kind\":\"template\"}"},
|
||||
{"/agent/sandbox/resource",
|
||||
"{\"name\":\"" + engine + "/sandboxEnvironmentSnapshots/8\",\"kind\":\"snapshot\"}"},
|
||||
{"/agent/sandbox/template",
|
||||
"{\"engine\":\"" + engine + "\",\"display_name\":\"t\",\"category\":\"computer\"}"},
|
||||
};
|
||||
for (const Case& c : cases) {
|
||||
auto res = f.client->post(c.route, c.body, "application/json");
|
||||
@@ -40,6 +59,15 @@ int main() {
|
||||
auto del = f.client->request(molo::example::fw::Method::Delete,
|
||||
"/agent/sandbox/delete?name=" + sandbox);
|
||||
check(del.status == 503, "delete answers 503 without a credential");
|
||||
auto del_op = f.client->request(molo::example::fw::Method::Delete,
|
||||
"/agent/sandbox/operation?name=" + sandbox + "/operations/1");
|
||||
check(del_op.status == 503 && contains(del_op.body, "google_not_configured"),
|
||||
"operation delete answers 503 without a credential");
|
||||
auto del_res = f.client->request(
|
||||
molo::example::fw::Method::Delete,
|
||||
"/agent/sandbox/resource?kind=template&name=" + engine + "/sandboxEnvironmentTemplates/7");
|
||||
check(del_res.status == 503 && contains(del_res.body, "google_not_configured"),
|
||||
"template delete answers 503 without a credential");
|
||||
check(contains(del.body, "google_not_configured"), "delete names the error");
|
||||
check(rig.mock->send_count() == 0, "side effect: no upstream traffic");
|
||||
return finish("agent/sandbox/not_configured");
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user