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:
+41
-6
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "clients/transports/http_transport.h"
|
||||
#include "google/credentials.h"
|
||||
#include "google/stream_decoder.h"
|
||||
|
||||
namespace molo::google {
|
||||
|
||||
@@ -25,13 +26,16 @@ std::shared_ptr<GoogleClient> GoogleClient::from_env() {
|
||||
Credentials::from_env());
|
||||
}
|
||||
|
||||
clients::body::Json GoogleClient::post_json(const ServiceEndpoint& service,
|
||||
const std::string& path,
|
||||
const clients::body::Json& body) {
|
||||
clients::body::Json GoogleClient::request(clients::Method method,
|
||||
const ServiceEndpoint& service,
|
||||
const std::string& path,
|
||||
const clients::body::Json* body) {
|
||||
if (!configured_) throw NotConfiguredError(service.name);
|
||||
try {
|
||||
return finish(service, client_.post_json_blocking(
|
||||
service.base_url + path, body));
|
||||
clients::ClientRequest req(method,
|
||||
clients::Url::parse(service.base_url + path));
|
||||
if (body) req.json(*body);
|
||||
return finish(service, client_.send_blocking(std::move(req)));
|
||||
} catch (const GoogleError&) {
|
||||
throw;
|
||||
} catch (const std::exception& e) {
|
||||
@@ -39,11 +43,42 @@ clients::body::Json GoogleClient::post_json(const ServiceEndpoint& service,
|
||||
}
|
||||
}
|
||||
|
||||
clients::body::Json GoogleClient::post_json(const ServiceEndpoint& service,
|
||||
const std::string& path,
|
||||
const clients::body::Json& body) {
|
||||
return request(clients::Method::kPost, service, path, &body);
|
||||
}
|
||||
|
||||
clients::body::Json GoogleClient::patch_json(const ServiceEndpoint& service,
|
||||
const std::string& path,
|
||||
const clients::body::Json& body) {
|
||||
return request(clients::Method::kPatch, service, path, &body);
|
||||
}
|
||||
|
||||
clients::body::Json GoogleClient::get_json(const ServiceEndpoint& service,
|
||||
const std::string& path) {
|
||||
return request(clients::Method::kGet, service, path, nullptr);
|
||||
}
|
||||
|
||||
clients::body::Json GoogleClient::delete_json(const ServiceEndpoint& service,
|
||||
const std::string& path) {
|
||||
return request(clients::Method::kDelete, service, path, nullptr);
|
||||
}
|
||||
|
||||
void GoogleClient::stream_json(const ServiceEndpoint& service,
|
||||
const std::string& path,
|
||||
const clients::body::Json& body,
|
||||
const EventSink& sink) {
|
||||
if (!configured_) throw NotConfiguredError(service.name);
|
||||
StreamDecoder decoder(service.name, sink);
|
||||
try {
|
||||
return finish(service, client_.get_blocking(service.base_url + path));
|
||||
clients::ClientRequest req(
|
||||
clients::Method::kPost, clients::Url::parse(service.base_url + path));
|
||||
req.json(body);
|
||||
client_.send_stream_blocking(
|
||||
std::move(req),
|
||||
[&](const std::string& chunk) { return decoder.feed(chunk); });
|
||||
decoder.finish();
|
||||
} catch (const GoogleError&) {
|
||||
throw;
|
||||
} catch (const std::exception& e) {
|
||||
|
||||
Reference in New Issue
Block a user