Merge adk and live gaps (YAML, VertexModel, live verification, TLS timeouts)

This commit is contained in:
2026-10-24 07:32:37 +02:00
34 changed files with 2920 additions and 655 deletions
+22 -9
View File
@@ -20,20 +20,33 @@ int main() {
"{\"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");
auto yi = post("/agent/adk/import", "name: root\nmodel: m\ninstruction: |\n Be brief.\ntools:\n - name: word_count\n");
check(yi.status == 200 && contains(yi.body, "\"word_count\"") && contains(yi.body, "Be brief."),
"import accepts ADK Agent Config YAML");
check(post("/agent/adk/import", "name: root\ninstruction: &a x\n").status == 422, "yaml anchors are 422");
check(post("/agent/adk/import", "name: a\ninstruction: x\nbefore_model_callbacks:\n - name: cb\n").status == 422,
"unsupported ADK field is 422");
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");
// AP2 v0.2: the checkout_hash is base64url(sha256(checkout_jwt)); for the
// jwt "abc" that is ungWv48Bz-pBQUDeXa4iI7ADYaOWF3qctBD_YfIAFa0.
std::string hash = "ungWv48Bz-pBQUDeXa4iI7ADYaOWF3qctBD_YfIAFa0";
std::string checkout = "{\"vct\":\"mandate.checkout.1\",\"checkout_jwt\":\"abc\",\"checkout_hash\":\"" + hash + "\"}";
std::string payment = "{\"vct\":\"mandate.payment.1\",\"transaction_id\":\"" + hash +
"\",\"payee\":{\"id\":\"m1\",\"name\":\"Shop\"},"
"\"payment_amount\":{\"amount\":27999,\"currency\":\"USD\"},"
"\"payment_instrument\":{\"id\":\"pi1\",\"type\":\"card\"}}";
check(post("/agent/adk/ap2/validate", "{\"checkout\":" + checkout + ",\"payment\":" + payment + "}").status == 200,
"valid checkout + payment mandate is 200");
std::string bad = checkout.substr(0, checkout.find(hash)) + "AAAA" + checkout.substr(checkout.find(hash) + 4);
check(post("/agent/adk/ap2/validate", "{\"checkout\":" + bad + "}").status == 422, "hash mismatch is 422");
check(post("/agent/adk/ap2/validate", "{\"checkout\":" + checkout + ",\"payment\":" +
payment.replace(payment.find(hash), hash.size(), "other") + "}").status == 422,
"payment for another checkout is 422");
check(post("/agent/adk/ap2/validate", "{}").status == 422, "empty body 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");