feat(clients): google foundation for the agent platform: all-verb client, streaming, typed Gemini content, operations
GoogleClient gets every verb and stream_json (SSE and plain JSON), typed Content/Part/Tool/GenerateRequest with the LanguageModel seam, CloudContext resource names, long-running operation polling and pagination, OAuth bearer tokens via GOOGLE_ACCESS_TOKEN. Example scaffold: one stub per agent module under example/app/agent, wildcard builds, locust excludes /voice /google /agent. plans/16-agent-platform.md splits the work into nine modules. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
// Agent Platform demos. One register function per module, each in its own
|
||||
// file under example/app/agent/. Every route lives under /agent/<module> and
|
||||
// is excluded from locust (paid Google APIs). Rules for a demo:
|
||||
// - GET pages and status routes answer 2xx without credentials (the matrix
|
||||
// test crawls them); anything that calls Google is a POST and answers 503
|
||||
// google_not_configured without a credential.
|
||||
// - State lives in objects created inside the register function and
|
||||
// captured by the handlers; do not edit Services.
|
||||
// - The Google client is services.google (null: GoogleClient::from_env()).
|
||||
|
||||
#include "App.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
void register_agent_models_demo(fw::Router& router, Services& services);
|
||||
void register_agent_runtime_demo(fw::Router& router, Services& services);
|
||||
void register_agent_sessions_demo(fw::Router& router, Services& services);
|
||||
void register_agent_sandbox_demo(fw::Router& router, Services& services);
|
||||
void register_agent_registry_demo(fw::Router& router, Services& services);
|
||||
void register_agent_armor_demo(fw::Router& router, Services& services);
|
||||
void register_agent_optimize_demo(fw::Router& router, Services& services);
|
||||
void register_agent_adk_demo(fw::Router& router, Services& services);
|
||||
void register_agent_live_demo(fw::Router& router, Services& services);
|
||||
|
||||
// Mounts every module's router at "" (called once from build_application).
|
||||
void register_agent_demos(std::shared_ptr<fw::Application> app, Services& services);
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "App.hpp"
|
||||
#include "AgentDemos.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
@@ -71,6 +72,8 @@ std::shared_ptr<fw::Application> build_application(Services& services) {
|
||||
register_voice_demo(voice, services);
|
||||
app->include_router("", voice);
|
||||
|
||||
register_agent_demos(app, services);
|
||||
|
||||
register_chain_demo(app, services);
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../AgentDemos.hpp"
|
||||
|
||||
#include "../../fw/Router.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
// Agent Platform: adk. Stub: the module agent fills this in.
|
||||
void register_agent_adk_demo(fw::Router& router, Services& services) {
|
||||
(void)router;
|
||||
(void)services;
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "../AgentDemos.hpp"
|
||||
|
||||
#include "../../fw/Router.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
void register_agent_demos(std::shared_ptr<fw::Application> app, Services& services) {
|
||||
{
|
||||
fw::Router r;
|
||||
register_agent_models_demo(r, services);
|
||||
app->include_router("", r);
|
||||
}
|
||||
{
|
||||
fw::Router r;
|
||||
register_agent_runtime_demo(r, services);
|
||||
app->include_router("", r);
|
||||
}
|
||||
{
|
||||
fw::Router r;
|
||||
register_agent_sessions_demo(r, services);
|
||||
app->include_router("", r);
|
||||
}
|
||||
{
|
||||
fw::Router r;
|
||||
register_agent_sandbox_demo(r, services);
|
||||
app->include_router("", r);
|
||||
}
|
||||
{
|
||||
fw::Router r;
|
||||
register_agent_registry_demo(r, services);
|
||||
app->include_router("", r);
|
||||
}
|
||||
{
|
||||
fw::Router r;
|
||||
register_agent_armor_demo(r, services);
|
||||
app->include_router("", r);
|
||||
}
|
||||
{
|
||||
fw::Router r;
|
||||
register_agent_optimize_demo(r, services);
|
||||
app->include_router("", r);
|
||||
}
|
||||
{
|
||||
fw::Router r;
|
||||
register_agent_adk_demo(r, services);
|
||||
app->include_router("", r);
|
||||
}
|
||||
{
|
||||
fw::Router r;
|
||||
register_agent_live_demo(r, services);
|
||||
app->include_router("", r);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../AgentDemos.hpp"
|
||||
|
||||
#include "../../fw/Router.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
// Agent Platform: armor. Stub: the module agent fills this in.
|
||||
void register_agent_armor_demo(fw::Router& router, Services& services) {
|
||||
(void)router;
|
||||
(void)services;
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../AgentDemos.hpp"
|
||||
|
||||
#include "../../fw/Router.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
// Agent Platform: live. Stub: the module agent fills this in.
|
||||
void register_agent_live_demo(fw::Router& router, Services& services) {
|
||||
(void)router;
|
||||
(void)services;
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../AgentDemos.hpp"
|
||||
|
||||
#include "../../fw/Router.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
// Agent Platform: models. Stub: the module agent fills this in.
|
||||
void register_agent_models_demo(fw::Router& router, Services& services) {
|
||||
(void)router;
|
||||
(void)services;
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../AgentDemos.hpp"
|
||||
|
||||
#include "../../fw/Router.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
// Agent Platform: optimize. Stub: the module agent fills this in.
|
||||
void register_agent_optimize_demo(fw::Router& router, Services& services) {
|
||||
(void)router;
|
||||
(void)services;
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../AgentDemos.hpp"
|
||||
|
||||
#include "../../fw/Router.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
// Agent Platform: registry. Stub: the module agent fills this in.
|
||||
void register_agent_registry_demo(fw::Router& router, Services& services) {
|
||||
(void)router;
|
||||
(void)services;
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../AgentDemos.hpp"
|
||||
|
||||
#include "../../fw/Router.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
// Agent Platform: runtime. Stub: the module agent fills this in.
|
||||
void register_agent_runtime_demo(fw::Router& router, Services& services) {
|
||||
(void)router;
|
||||
(void)services;
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../AgentDemos.hpp"
|
||||
|
||||
#include "../../fw/Router.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
// Agent Platform: sandbox. Stub: the module agent fills this in.
|
||||
void register_agent_sandbox_demo(fw::Router& router, Services& services) {
|
||||
(void)router;
|
||||
(void)services;
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../AgentDemos.hpp"
|
||||
|
||||
#include "../../fw/Router.hpp"
|
||||
|
||||
namespace molo::example::app {
|
||||
|
||||
// Agent Platform: sessions. Stub: the module agent fills this in.
|
||||
void register_agent_sessions_demo(fw::Router& router, Services& services) {
|
||||
(void)router;
|
||||
(void)services;
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
@@ -15,6 +15,14 @@ LOCUST = HERE / "locustfile.py"
|
||||
# Routes that call paid Google APIs: never load tested. The check fails if
|
||||
# locust references one, and does not require them to be covered.
|
||||
EXCLUDED = {"/voice/say", "/voice/hear", "/voice/turn", "/voice/reset"}
|
||||
# Whole areas that talk to (or front) paid Google APIs. Routes under these
|
||||
# prefixes are never load tested and never required to be covered.
|
||||
EXCLUDED_PREFIXES = ("/voice", "/google", "/agent", "/embedded/voice.js",
|
||||
"/embedded/agent_")
|
||||
|
||||
|
||||
def is_excluded(route: str) -> bool:
|
||||
return route in EXCLUDED or route.startswith(EXCLUDED_PREFIXES)
|
||||
|
||||
FILLS = {"name": "locust", "id": "1", "status": "404", "tenant": "acme"}
|
||||
|
||||
@@ -59,7 +67,7 @@ def main() -> int:
|
||||
routes = collect_routes()
|
||||
urls, methods = collect_locust_urls()
|
||||
missing: list[str] = []
|
||||
for r in sorted(routes - EXCLUDED):
|
||||
for r in sorted(r for r in routes if not is_excluded(r)):
|
||||
c = fill(r)
|
||||
ok = (
|
||||
c in urls
|
||||
@@ -72,7 +80,7 @@ def main() -> int:
|
||||
)
|
||||
if not ok:
|
||||
missing.append(f"{r} -> {c}")
|
||||
leaked = sorted(EXCLUDED & urls)
|
||||
leaked = sorted(u for u in urls if is_excluded(u))
|
||||
for r in leaked:
|
||||
print("FORBIDDEN (costs money):", r)
|
||||
required_methods = {"get", "post", "put", "options"}
|
||||
@@ -88,7 +96,8 @@ def main() -> int:
|
||||
if missing or missing_methods:
|
||||
print(f"FAIL: {len(missing)} missing routes, {len(missing_methods)} missing methods")
|
||||
return 1
|
||||
print(f"OK: {len(routes) - len(EXCLUDED)} routes covered, {len(EXCLUDED)} paid Google routes excluded, methods {sorted(methods)}")
|
||||
excluded = sum(1 for r in routes if is_excluded(r))
|
||||
print(f"OK: {len(routes) - excluded} routes covered, {excluded} paid Google routes excluded, methods {sorted(methods)}")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
+4
-7
@@ -53,7 +53,8 @@ EXAMPLE_SRCS = \
|
||||
$(EXAMPLE_DIR)/app/PlatformDemo.cpp \
|
||||
$(EXAMPLE_DIR)/app/EnterpriseDemo.cpp \
|
||||
$(EXAMPLE_DIR)/app/ResilienceDemo.cpp \
|
||||
$(EXAMPLE_DIR)/app/VoiceDemo.cpp
|
||||
$(EXAMPLE_DIR)/app/VoiceDemo.cpp \
|
||||
$(sort $(wildcard $(EXAMPLE_DIR)/app/agent/*.cpp))
|
||||
|
||||
# Tests are discovered: every tests/example/**/*_test.cpp is one route test.
|
||||
EXAMPLE_TEST_JOBS ?= 8
|
||||
@@ -65,12 +66,8 @@ EXAMPLE_EMBED_SRCS = \
|
||||
src/cli/embed/gzip_stored.cpp \
|
||||
src/cli/embed/mime.cpp \
|
||||
src/cli/embed/sha256.cpp
|
||||
EXAMPLE_ASSETS = \
|
||||
$(EXAMPLE_DIR)/assets/app.css \
|
||||
$(EXAMPLE_DIR)/assets/chart.umd.min.js \
|
||||
$(EXAMPLE_DIR)/assets/hello.txt \
|
||||
$(EXAMPLE_DIR)/assets/stats.js \
|
||||
$(EXAMPLE_DIR)/assets/voice.js
|
||||
# Every file in example/assets is embedded (agent modules add agent_<module>.js).
|
||||
EXAMPLE_ASSETS = $(sort $(wildcard $(EXAMPLE_DIR)/assets/*))
|
||||
EXAMPLE_INC = -I$(EXAMPLE_DIR) -I$(EXAMPLE_BUILD) -Isrc
|
||||
# Real framework parts the example links: Google Cloud (src/google) over the
|
||||
# HTTP client (src/clients, wolfSSL TLS) and the operability breaker.
|
||||
|
||||
@@ -39,7 +39,6 @@ GETS = [
|
||||
"/csp/page", "/csp/report",
|
||||
"/di/services", "/di/resolve/locust",
|
||||
"/embedded/chart.umd.min.js", "/embedded/hello.txt", "/embedded/stats.js",
|
||||
"/embedded/voice.js", "/google/status", "/voice",
|
||||
"/events/fire", "/expose/record", "/expose/stats",
|
||||
"/files/", "/files/welcome.txt",
|
||||
"/flash", "/flash/set",
|
||||
@@ -88,8 +87,8 @@ GETS = [
|
||||
"/webdav/files/test.txt",
|
||||
]
|
||||
|
||||
# NOT load tested on purpose: /voice/say, /voice/hear, /voice/turn and
|
||||
# /voice/reset call paid Google APIs (check_locust_coverage.py enforces this).
|
||||
# NOT load tested on purpose: everything under /voice, /google and /agent
|
||||
# calls or fronts paid Google APIs (check_locust_coverage.py enforces this).
|
||||
POSTS = [
|
||||
("/audit/log", {"event": "locust"}),
|
||||
("/audit/retention/hold", {"hold": True}),
|
||||
|
||||
Reference in New Issue
Block a user