feat(clients): runtime: Agent Engine reasoningEngines client, discovery-checked call table, typed deployment spec, demo routes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 04:31:12 +02:00
co-authored by Claude Sonnet 5.5
parent 6d744a433f
commit fedee6d03a
22 changed files with 2262 additions and 3 deletions
@@ -0,0 +1,21 @@
// Route: POST /agent/runtime/create (starts the operation, never waits)
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig rig(false);
Fixture f(rig.client);
std::string ok = "{\"displayName\":\"Agent\",\"agentFramework\":\"google-adk\",\"imageUri\":\"us-docker.pkg.dev/p/r/a:1\",\"maxInstances\":10,\"cpu\":\"4\",\"memory\":\"8Gi\"}";
auto res = f.client->post("/agent/runtime/create", ok, "application/json");
check(res.status == 503 && contains(res.body, "google_not_configured"), "no credential is 503");
check(f.client->post("/agent/runtime/create", "{}", "application/json").status == 422, "missing displayName is 422");
check(f.client->post("/agent/runtime/create", "{\"displayName\":\"a\",\"maxInstances\":5000}", "application/json").status == 422, "maxInstances over 1000 is 422");
check(f.client->post("/agent/runtime/create", "{\"displayName\":\"a\",\"cpu\":\"3\"}", "application/json").status == 422, "cpu 3 is 422");
check(f.client->post("/agent/runtime/create", "{\"displayName\":\"a\",\"identityType\":\"AGENT_IDENTITY\",\"serviceAccount\":\"a@b.c\"}", "application/json").status == 422, "agent identity with service account is 422");
check(f.client->post("/agent/runtime/create", "{\"displayName\":\"a\",\"agentFramework\":\"magic\"}", "application/json").status == 422, "unknown framework is 422");
check(f.client->get("/agent/runtime/create").status == 405, "get is 405");
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("agent/runtime/create");
}
@@ -0,0 +1,20 @@
// Route: POST /agent/runtime/delete (dry run unless confirm:true)
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig rig(false);
Fixture f(rig.client);
auto dry = f.client->post("/agent/runtime/delete", "{\"id\":\"123\",\"force\":true}", "application/json");
check(dry.status == 200 && contains(dry.body, "\"dry_run\":true") && contains(dry.body, "\"force\":true"), "default is a dry run");
auto real = f.client->post("/agent/runtime/delete", "{\"id\":\"123\",\"confirm\":true}", "application/json");
check(real.status == 503 && contains(real.body, "google_not_configured"), "confirmed delete without credential is 503");
check(f.client->post("/agent/runtime/delete", "{}", "application/json").status == 422, "missing id is 422");
check(f.client->post("/agent/runtime/delete", "{\"id\":\"1\",\"force\":\"yes\"}", "application/json").status == 422, "non-bool force is 422");
check(f.client->post("/agent/runtime/delete", "{\"id\":\"1\",\"confirm\":\"yes\"}", "application/json").status == 422, "non-bool confirm is 422");
check(f.client->get("/agent/runtime/delete").status == 405, "get is 405");
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("agent/runtime/delete");
}
+18
View File
@@ -0,0 +1,18 @@
// Route: POST /agent/runtime/get
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig rig(false);
Fixture f(rig.client);
auto res = f.client->post("/agent/runtime/get", "{\"id\":\"123\"}", "application/json");
check(res.status == 503 && contains(res.body, "google_not_configured"), "no credential is 503");
check(f.client->post("/agent/runtime/get", "{}", "application/json").status == 422, "missing id is 422");
check(f.client->post("/agent/runtime/get", "{\"id\":\"../x\"}", "application/json").status == 422, "traversal id is 422");
check(f.client->post("/agent/runtime/get", "{\"id\":\"a/b\"}", "application/json").status == 422, "slash id is 422");
check(f.client->get("/agent/runtime/get").status == 405, "get is 405");
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("agent/runtime/get");
}
+19
View File
@@ -0,0 +1,19 @@
// Route: POST /agent/runtime/list
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig rig(false);
Fixture f(rig.client);
auto res = f.client->post("/agent/runtime/list", "{}", "application/json");
check(res.status == 503 && contains(res.body, "google_not_configured"), "no credential is 503");
check(f.client->post("/agent/runtime/list", "not json", "application/json").status == 422, "bad json is 422");
check(f.client->post("/agent/runtime/list", "{\"filter\":5}", "application/json").status == 422, "non-string filter is 422");
check(f.client->post("/agent/runtime/list", "{\"filter\":\"" + std::string(600, 'f') + "\"}", "application/json").status == 422, "filter over cap is 422");
check(f.client->post("/agent/runtime/list", std::string(300 * 1024, 'a'), "application/json").status == 413, "body over cap is 413");
check(f.client->get("/agent/runtime/list").status == 405, "get is 405");
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("agent/runtime/list");
}
@@ -0,0 +1,21 @@
// Route: POST /agent/runtime/operation and /agent/runtime/async
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig rig(false);
Fixture f(rig.client);
auto op = f.client->post("/agent/runtime/operation", "{\"name\":\"projects/p/locations/l/operations/1\"}", "application/json");
check(op.status == 503 && contains(op.body, "google_not_configured"), "operation: no credential is 503");
check(f.client->post("/agent/runtime/operation", "{\"name\":\"../etc\"}", "application/json").status == 422, "operation: bad name is 422");
check(f.client->post("/agent/runtime/operation", "{}", "application/json").status == 422, "operation: missing name is 422");
auto as = f.client->post("/agent/runtime/async", "{\"id\":\"1\",\"inputGcsUri\":\"gs://in/q.json\",\"outputGcsUri\":\"gs://out/r.json\"}", "application/json");
check(as.status == 503 && contains(as.body, "google_not_configured"), "async: no credential is 503");
check(f.client->post("/agent/runtime/async", "{\"id\":\"1\",\"inputGcsUri\":\"http://x\",\"outputGcsUri\":\"gs://o\"}", "application/json").status == 422, "async: non gs uri is 422");
check(f.client->get("/agent/runtime/operation").status == 405, "operation: get is 405");
check(f.client->get("/agent/runtime/async").status == 405, "async: get is 405");
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("agent/runtime/operation");
}
+18
View File
@@ -0,0 +1,18 @@
// Route: GET /agent/runtime (page, no credential needed)
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig rig(false);
Fixture f(rig.client);
auto res = f.client->get("/agent/runtime");
check(res.status == 200, "status 200");
check(contains(res.headers.get("Content-Type"), "text/html"), "html");
check(contains(res.body, "Agent Runtime") && contains(res.body, "viewport"), "page and mobile viewport");
check(contains(res.body, "/embedded/agent_runtime.js"), "script wired");
check(f.client->post("/agent/runtime", "{}", "application/json").status == 405, "post is 405");
check(rig.mock->send_count() == 0, "no network");
return finish("agent/runtime");
}
@@ -0,0 +1,20 @@
// Route: POST /agent/runtime/query and /agent/runtime/stream
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig rig(false);
Fixture f(rig.client);
for (std::string route : {"/agent/runtime/query", "/agent/runtime/stream"}) {
auto res = f.client->post(route, "{\"id\":\"123\",\"input\":{\"message\":\"hi\"}}", "application/json");
check(res.status == 503 && contains(res.body, "google_not_configured"), route + " no credential is 503");
check(f.client->post(route, "{\"input\":{}}", "application/json").status == 422, route + " missing id is 422");
check(f.client->post(route, "{\"id\":\"1\",\"input\":\"text\"}", "application/json").status == 422, route + " non-object input is 422");
check(f.client->post(route, "{\"id\":\"1\",\"classMethod\":\"bad method\"}", "application/json").status == 422, route + " bad classMethod is 422");
check(f.client->get(route).status == 405, route + " get is 405");
}
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("agent/runtime/query");
}
@@ -0,0 +1,24 @@
// Route: GET /agent/runtime/status and /agent/runtime/calls
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig off(false);
Fixture f(off.client);
auto res = f.client->get("/agent/runtime/status");
check(res.status == 200, "status 200");
check(contains(res.body, "\"configured\":false"), "reports no credential");
check(contains(res.body, "\"project_set\":true"), "project read from env");
auto calls = f.client->get("/agent/runtime/calls");
check(calls.status == 200, "calls 200");
check(contains(calls.body, "aiplatform.projects.locations.reasoningEngines.streamQuery"), "table lists streamQuery");
check(contains(calls.body, "v1beta1/{+name}:query"), "table lists runtime revision query");
GoogleRig on;
Fixture g(on.client);
check(contains(g.client->get("/agent/runtime/status").body, "\"configured\":true"), "reports credential");
check(f.client->post("/agent/runtime/status", "{}", "application/json").status == 405, "post is 405");
check(on.mock->send_count() == 0, "no network");
return finish("agent/runtime/status");
}