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:
2026-10-24 04:12:52 +02:00
co-authored by Claude Sonnet 5.5
parent 837de58136
commit 6d744a433f
32 changed files with 1536 additions and 22 deletions
+48
View File
@@ -0,0 +1,48 @@
#pragma once
// Long-running operations (google.longrunning) and pagination, shared by
// every module that creates, deletes or lists Cloud resources.
#include <chrono>
#include <functional>
#include <string>
#include <vector>
#include "google/client.h"
namespace molo::google {
struct Operation {
std::string name; // projects/.../operations/{id}
bool done = false;
clients::body::Json response; // Set when done and successful.
clients::body::Json metadata;
int error_code = 0; // google.rpc.Status, 0: no error
std::string error_message;
bool failed() const { return error_code != 0; }
static Operation from_json(const clients::body::Json& doc);
};
struct OperationCaps {
static constexpr std::chrono::seconds kMaxWait{600};
static constexpr std::chrono::milliseconds kInterval{2000};
static constexpr std::size_t kMaxPolls = 400;
};
using Sleeper = std::function<void(std::chrono::milliseconds)>;
// Polls GET {name} on the given endpoint until done. Throws GoogleError
// (status DEADLINE_EXCEEDED) at the cap and (status from the operation, or
// UNKNOWN) when the operation failed. `sleeper` is injectable for tests.
Operation wait_operation(GoogleClient& client, const ServiceEndpoint& endpoint,
const std::string& operation_name,
const Sleeper& sleeper = nullptr);
// Follows nextPageToken. `path` may already hold a query string. Collects
// `items_key` arrays into one Json array; stops at max_pages (default 100).
clients::body::Json list_all(GoogleClient& client, const ServiceEndpoint& endpoint,
const std::string& path, const std::string& items_key,
std::size_t max_pages = 100);
} // namespace molo::google