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,76 @@
|
||||
#pragma once
|
||||
|
||||
// Batch and event-driven triggers as plain local interfaces. The Agent
|
||||
// Runtime triggers (BigQuery, Pub/Sub) belong to the runtime module; this
|
||||
// seam only says "something produced work for an agent". A Trigger yields
|
||||
// events; TriggerDispatcher runs one agent turn per event with hard caps.
|
||||
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "google/adk/runner.h"
|
||||
|
||||
namespace molo::google::adk {
|
||||
|
||||
struct TriggerEvent {
|
||||
std::string id; // Used as the session id: [A-Za-z0-9._-], 1..128
|
||||
std::string payload; // Becomes the user message
|
||||
};
|
||||
|
||||
class Trigger {
|
||||
public:
|
||||
virtual ~Trigger() = default;
|
||||
// Returns at most max_events pending events and removes them.
|
||||
virtual std::vector<TriggerEvent> poll(std::size_t max_events) = 0;
|
||||
};
|
||||
|
||||
// Event-driven: a producer pushes, the dispatcher polls. Bounded queue;
|
||||
// push returns false (and counts a drop) when full.
|
||||
class QueueTrigger : public Trigger {
|
||||
public:
|
||||
bool push(TriggerEvent event);
|
||||
std::vector<TriggerEvent> poll(std::size_t max_events) override;
|
||||
std::size_t dropped() const;
|
||||
std::size_t pending() const;
|
||||
|
||||
private:
|
||||
mutable std::mutex mutex_;
|
||||
std::deque<TriggerEvent> queue_;
|
||||
std::size_t dropped_ = 0;
|
||||
};
|
||||
|
||||
// Batch: a fixed list of inputs handed out in slices.
|
||||
class BatchTrigger : public Trigger {
|
||||
public:
|
||||
explicit BatchTrigger(std::vector<TriggerEvent> events);
|
||||
std::vector<TriggerEvent> poll(std::size_t max_events) override;
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::deque<TriggerEvent> queue_;
|
||||
};
|
||||
|
||||
struct DispatchOutcome {
|
||||
std::string event_id;
|
||||
bool ok = false;
|
||||
std::string error; // Set when !ok
|
||||
RunResult result;
|
||||
};
|
||||
|
||||
class TriggerDispatcher {
|
||||
public:
|
||||
TriggerDispatcher(std::shared_ptr<Runner> runner, std::shared_ptr<BaseAgent> agent)
|
||||
: runner_(std::move(runner)), agent_(std::move(agent)) {}
|
||||
// One poll of at most max_events (capped at kMaxTriggerBatch). A failing
|
||||
// event is reported in its outcome and does not stop the rest.
|
||||
std::vector<DispatchOutcome> dispatch(Trigger& trigger, std::size_t max_events);
|
||||
|
||||
private:
|
||||
std::shared_ptr<Runner> runner_;
|
||||
std::shared_ptr<BaseAgent> agent_;
|
||||
};
|
||||
|
||||
} // namespace molo::google::adk
|
||||
Reference in New Issue
Block a user