feat(clients): adk: agents, tools, runner with hard caps, multi-agent graph, MCP and A2A clients, Studio export, Garden, AP2, triggers
DirectModel over GoogleClient with thought-signature replay, discovery check script, live verified against the real model (function calling, transfer, MCP). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// Routes: GET /agent/adk, /agent/adk/status, /agent/adk/garden
|
||||
#include "support/GoogleRig.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
GoogleRig none(false);
|
||||
Fixture f(none.client);
|
||||
auto page = f.client->get("/agent/adk");
|
||||
check(page.status == 200, "page 200 without a credential");
|
||||
check(contains(page.body, "agent_adk.js") && contains(page.body, "adk-run"), "page has the runner UI");
|
||||
auto st = f.client->get("/agent/adk/status");
|
||||
check(st.status == 200 && contains(st.body, "\"configured\":false"), "status shows not configured");
|
||||
check(contains(st.body, "\"max_steps\":12") && contains(st.body, "\"max_tool_calls\":24"), "caps shown");
|
||||
auto g = f.client->get("/agent/adk/garden");
|
||||
check(g.status == 200, "garden 200");
|
||||
for (const char* id : {"code_modernization", "financial_analysis", "economic_research", "invoice_processing"})
|
||||
check(contains(g.body, id), std::string("garden lists ") + id);
|
||||
check(none.mock->send_count() == 0, "side effect: no upstream traffic");
|
||||
check(f.client->post("/agent/adk").status == 405, "post page is 405");
|
||||
check(f.client->post("/agent/adk/garden").status == 405, "post garden is 405");
|
||||
check(f.client->get("/agent/adk/run").status == 405, "get run is 405");
|
||||
return finish("agent/adk page");
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Route: POST /agent/adk/run (validation and credential gate; the model call
|
||||
// itself is proven live in the google suite, not scripted here)
|
||||
#include "support/GoogleRig.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
GoogleRig none(false);
|
||||
Fixture f(none.client);
|
||||
auto post = [&](const std::string& body) {
|
||||
return f.client->post("/agent/adk/run", body, "application/json");
|
||||
};
|
||||
auto ok = post("{\"prompt\":\"total of 2 and 3?\",\"template\":\"financial_analysis\"}");
|
||||
check(ok.status == 503 && contains(ok.body, "google_not_configured"), "no credential is a loud 503");
|
||||
check(post("not json").status == 422, "bad json is 422");
|
||||
check(post("{\"prompt\":\"\"}").status == 422, "empty prompt is 422");
|
||||
check(post("{\"prompt\":\"" + std::string(2001, 'x') + "\"}").status == 422, "prompt over cap is 422");
|
||||
check(post("{\"prompt\":\"hi\",\"template\":\"nope\"}").status == 422, "unknown template is 422");
|
||||
check(none.mock->send_count() == 0, "side effect: nothing sent without a credential");
|
||||
|
||||
GoogleRig keyed;
|
||||
Fixture g(keyed.client);
|
||||
check(g.client->post("/agent/adk/run", "{\"prompt\":\"\"}", "application/json").status == 422,
|
||||
"validation also runs with a credential");
|
||||
check(g.client->post("/agent/adk/run", "{\"prompt\":\"hi\",\"cid\":\"bad id!\"}", "application/json").status == 422,
|
||||
"bad session id is 422");
|
||||
check(keyed.mock->send_count() == 0, "rejected input never reached Google");
|
||||
return finish("agent/adk run");
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Routes: POST /agent/adk/export, /agent/adk/import, /agent/adk/ap2/validate
|
||||
#include "support/GoogleRig.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
GoogleRig none(false);
|
||||
Fixture f(none.client);
|
||||
auto post = [&](const std::string& path, const std::string& body) {
|
||||
return f.client->post(path, body, "application/json");
|
||||
};
|
||||
auto ex = post("/agent/adk/export", "{\"template\":\"invoice_processing\"}");
|
||||
check(ex.status == 200 && contains(ex.body, "\"agent_class\":\"LlmAgent\"") &&
|
||||
contains(ex.body, "invoice_processing"),
|
||||
"export returns the definition");
|
||||
check(contains(ex.body, "\"yaml\":"), "export includes yaml");
|
||||
check(post("/agent/adk/export", "{\"template\":\"nope\"}").status == 422, "unknown template is 422");
|
||||
|
||||
std::string def = "{\"agent_class\":\"SequentialAgent\",\"name\":\"flow\",\"sub_agents\":["
|
||||
"{\"name\":\"a\",\"model\":\"m\",\"instruction\":\"x\",\"tools\":[{\"name\":\"word_count\"}]}]}";
|
||||
auto im = post("/agent/adk/import", def);
|
||||
check(im.status == 200 && contains(im.body, "\"word_count\""), "import round-trips a known tool");
|
||||
check(post("/agent/adk/import", "{\"name\":\"a\",\"tools\":[{\"name\":\"ghost\"}]}").status == 422,
|
||||
"unknown tool is 422");
|
||||
check(post("/agent/adk/import", "{\"name\":\"a\",\"agent_class\":\"Evil\"}").status == 422, "bad class is 422");
|
||||
check(post("/agent/adk/import", "oops").status == 422, "bad json is 422");
|
||||
|
||||
std::string intent = "{\"id\":\"i1\",\"description\":\"sleeve\",\"max_amount_minor\":5000,\"currency\":\"EUR\"}";
|
||||
std::string cart = "{\"id\":\"c1\",\"intent_id\":\"i1\",\"merchant\":\"m\",\"items\":["
|
||||
"{\"sku\":\"s\",\"quantity\":2,\"unit_amount_minor\":1500}],\"total_minor\":3000,\"currency\":\"EUR\"}";
|
||||
check(post("/agent/adk/ap2/validate", "{\"intent\":" + intent + ",\"cart\":" + cart + "}").status == 200,
|
||||
"valid mandate chain is 200");
|
||||
std::string bad_cart = cart.substr(0, cart.find("3000,")) + "9999," + cart.substr(cart.find("3000,") + 5);
|
||||
check(post("/agent/adk/ap2/validate", "{\"intent\":" + intent + ",\"cart\":" + bad_cart + "}").status == 422,
|
||||
"cart total mismatch is 422");
|
||||
check(post("/agent/adk/ap2/validate", "{}").status == 422, "missing intent is 422");
|
||||
check(f.client->get("/agent/adk/export").status == 405, "get export is 405");
|
||||
check(none.mock->send_count() == 0, "none of these routes call Google");
|
||||
return finish("agent/adk studio");
|
||||
}
|
||||
Reference in New Issue
Block a user