Skip to content
Draft
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
013572f
Decouple extended agent card from transports
MisterVVP Jun 29, 2026
7c96d6e
Fix extended agent card build regressions
MisterVVP Jun 29, 2026
f19e398
Fix benchmark and extended card routing regressions
MisterVVP Jun 29, 2026
db021fd
refactor: add non-copyable helper base classes
MisterVVP Jun 30, 2026
2308715
fix: clang fmt
Jun 30, 2026
83393bd
fix: propagate tenant to extended card provider
MisterVVP Jun 30, 2026
799cd82
fix: propagate tenant to extended card provider
MisterVVP Jun 30, 2026
2a1c2f0
fix: add tenant parameter to REST extended card handler
MisterVVP Jun 30, 2026
2e61429
fix: route extended card discovery requests
MisterVVP Jun 30, 2026
a15590a
test: cover REST extended card discovery routes
MisterVVP Jun 30, 2026
6d0489b
fix: clang fmt
Jun 30, 2026
9f97459
fix: use spec extended card discovery endpoint
MisterVVP Jun 30, 2026
ff93572
test: cover spec extended card discovery URL
MisterVVP Jun 30, 2026
8029bf5
address review threads
Jun 30, 2026
b4ec4c2
fix: clang tidy optional access
MisterVVP Jun 30, 2026
25b8866
fix: route tenant extended cards through mux
MisterVVP Jul 1, 2026
d752fe8
fix dispatcher
Jul 1, 2026
5773705
Refactor shared HTTP protocol constants (#127)
MisterVVP Jul 1, 2026
7c1b72f
fix: accept extended agent card JSON-RPC alias
MisterVVP Jul 1, 2026
f92e3f6
add compatibility header
MisterVVP Jul 1, 2026
408109d
clang fmt
Jul 1, 2026
22c09b6
fix: return extended card error info reason
Jul 2, 2026
9a86db9
fix: remove deprecated agent card builder shim
MisterVVP Jul 2, 2026
00599ee
docs: document agent card builder include path removal
MisterVVP Jul 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/bench_agent_card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <benchmark/benchmark.h>

#include "a2a/core/agent_card_builder.h"
#include "a2a/core/agent_card/agent_card_builder.h"
#include "a2a/core/protojson.h"
#include "a2a/server/rest_server_transport.h"
#include "bench_common.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <unordered_map>
#include <utility>

#include "a2a/core/agent_card_builder.h"
#include "a2a/core/agent_card/agent_card_builder.h"
#include "a2a/core/protocol_bindings.h"
#include "a2a/core/protojson.h"
#include "a2a/core/result.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/auth_policy_server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "a2a/client/client.h"
#include "a2a/client/http_json_transport.h"
#include "a2a/core/agent_card_builder.h"
#include "a2a/core/agent_card/agent_card_builder.h"
#include "a2a/core/url_utils.h"
#include "a2a/server/agent_executor.h"
#include "a2a/server/dispatcher.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/hello_agent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "a2a/client/client.h"
#include "a2a/client/http_json_transport.h"
#include "a2a/core/agent_card_builder.h"
#include "a2a/core/agent_card/agent_card_builder.h"
#include "a2a/core/url_utils.h"
#include "a2a/server/agent_executor.h"
#include "a2a/server/dispatcher.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/json_rpc_server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "a2a/client/client.h"
#include "a2a/client/json_rpc_transport.h"
#include "a2a/core/agent_card_builder.h"
#include "a2a/core/agent_card/agent_card_builder.h"
#include "a2a/core/url_utils.h"
#include "a2a/server/agent_executor.h"
#include "a2a/server/dispatcher.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/rest_server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "a2a/client/client.h"
#include "a2a/client/http_json_transport.h"
#include "a2a/core/agent_card_builder.h"
#include "a2a/core/agent_card/agent_card_builder.h"
#include "a2a/core/url_utils.h"
#include "a2a/server/agent_executor.h"
#include "a2a/server/dispatcher.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/streaming_server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "a2a/client/client.h"
#include "a2a/client/http_json_transport.h"
#include "a2a/core/agent_card_builder.h"
#include "a2a/core/agent_card/agent_card_builder.h"
#include "a2a/core/url_utils.h"
#include "a2a/server/agent_executor.h"
#include "a2a/server/dispatcher.h"
Expand Down
5 changes: 2 additions & 3 deletions include/a2a/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <vector>

#include "a2a/client/call_options.h"
#include "a2a/core/non_copyable.h"
#include "a2a/core/result.h"
#include "a2a/v1/a2a.pb.h"

Expand Down Expand Up @@ -72,7 +73,7 @@ class StreamObserver {
virtual void OnCompleted() = 0;
};

class StreamHandle final {
class StreamHandle final : private core::NonCopyable {
public:
struct State final {
std::atomic<bool> cancel_requested{false};
Expand All @@ -82,8 +83,6 @@ class StreamHandle final {
};

StreamHandle() = delete;
StreamHandle(const StreamHandle&) = delete;
StreamHandle& operator=(const StreamHandle&) = delete;
StreamHandle(StreamHandle&&) noexcept;
StreamHandle& operator=(StreamHandle&&) noexcept;
~StreamHandle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AgentCardBuilder final {
AgentCardBuilder& AddDefaultInputMode(std::string_view mode);
AgentCardBuilder& AddDefaultOutputMode(std::string_view mode);
AgentCardBuilder& WithPushNotifications(bool enabled);
AgentCardBuilder& WithExtendedAgentCard(bool enabled);
AgentCardBuilder& AddExtension(std::string_view uri, bool required, std::string_view description = {});

struct InterfaceSpec final {
Expand Down
44 changes: 44 additions & 0 deletions include/a2a/core/agent_card/agent_card_provider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 Vladimir Pavlov <mistervvp@outlook.com> (https://github.com/MisterVVP)

#pragma once

#include <optional>
#include <string>
#include <unordered_map>

#include "a2a/core/non_copyable.h"
#include "a2a/core/result.h"
#include "a2a/v1/a2a.pb.h"

namespace a2a::core {

struct AgentCardRequestContext final {
std::optional<std::string> tenant;
std::optional<std::string> remote_address;
std::unordered_map<std::string, std::string> client_headers;
std::unordered_map<std::string, std::string> auth_metadata;
};

class AgentCardProvider : private NonCopyableOrMovable {
public:
AgentCardProvider() = default;
virtual ~AgentCardProvider() = default;

[[nodiscard]] virtual Result<lf::a2a::v1::AgentCard> GetExtendedAgentCard(
const AgentCardRequestContext& context) const = 0;
};

class StaticAgentCardProvider final : public AgentCardProvider {
public:
StaticAgentCardProvider() = default;
explicit StaticAgentCardProvider(std::optional<lf::a2a::v1::AgentCard> extended_agent_card);

[[nodiscard]] Result<lf::a2a::v1::AgentCard> GetExtendedAgentCard(
const AgentCardRequestContext& context) const override;

private:
std::optional<lf::a2a::v1::AgentCard> extended_agent_card_;
};

} // namespace a2a::core
3 changes: 2 additions & 1 deletion include/a2a/core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

#pragma once

#include "a2a/core/agent_card_builder.h"
#include "a2a/core/agent_card/agent_card_builder.h"
Comment thread
MisterVVP marked this conversation as resolved.
#include "a2a/core/agent_card/agent_card_provider.h"
#include "a2a/core/error.h"
#include "a2a/core/extensions.h"
#include "a2a/core/protojson.h"
Expand Down
32 changes: 32 additions & 0 deletions include/a2a/core/non_copyable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 Vladimir Pavlov <mistervvp@outlook.com> (https://github.com/MisterVVP)

#pragma once

namespace a2a::core {

class NonCopyable {
public:
NonCopyable(const NonCopyable&) = delete;
NonCopyable& operator=(const NonCopyable&) = delete;

protected:
constexpr NonCopyable() noexcept = default;
constexpr NonCopyable(NonCopyable&&) noexcept = default;
constexpr NonCopyable& operator=(NonCopyable&&) noexcept = default;
~NonCopyable() = default;
};

class NonCopyableOrMovable {
public:
NonCopyableOrMovable(const NonCopyableOrMovable&) = delete;
NonCopyableOrMovable& operator=(const NonCopyableOrMovable&) = delete;
NonCopyableOrMovable(NonCopyableOrMovable&&) = delete;
NonCopyableOrMovable& operator=(NonCopyableOrMovable&&) = delete;

protected:
constexpr NonCopyableOrMovable() noexcept = default;
~NonCopyableOrMovable() = default;
};

} // namespace a2a::core
1 change: 1 addition & 0 deletions include/a2a/core/protocol_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ inline constexpr std::string_view kCreateTaskPushNotificationConfig = "CreateTas
inline constexpr std::string_view kGetTaskPushNotificationConfig = "GetTaskPushNotificationConfig";
inline constexpr std::string_view kListTaskPushNotificationConfigs = "ListTaskPushNotificationConfigs";
inline constexpr std::string_view kDeleteTaskPushNotificationConfig = "DeleteTaskPushNotificationConfig";
inline constexpr std::string_view kGetExtendedAgentCard = "GetExtendedAgentCard";
inline constexpr std::string_view kPushNotificationConfigsSegment = "/pushNotificationConfigs";

} // namespace a2a::core::protocol_methods
19 changes: 19 additions & 0 deletions include/a2a/server/agent_card/agent_card_serializer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 Vladimir Pavlov <mistervvp@outlook.com> (https://github.com/MisterVVP)

#pragma once

#include <google/protobuf/struct.pb.h>

#include "a2a/core/result.h"
#include "a2a/v1/a2a.pb.h"

namespace a2a::server {

[[nodiscard]] core::Result<google::protobuf::Struct> BuildNormalizedAgentCard(const lf::a2a::v1::AgentCard& agent_card,
bool include_legacy_transport_fields);

[[nodiscard]] core::Result<google::protobuf::Value> BuildAgentCardJsonValue(const lf::a2a::v1::AgentCard& agent_card,
bool include_legacy_transport_fields);

} // namespace a2a::server
12 changes: 8 additions & 4 deletions include/a2a/server/dispatch_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@ enum class DispatcherOperation : std::uint8_t {
kGetTaskPushNotificationConfig,
kListTaskPushNotificationConfigs,
kDeleteTaskPushNotificationConfig,
kGetExtendedAgentCard,
};

struct DispatchRequest final {
DispatcherOperation operation = DispatcherOperation::kSendMessage;
std::variant<lf::a2a::v1::SendMessageRequest, lf::a2a::v1::GetTaskRequest, ListTasksRequest,
lf::a2a::v1::CancelTaskRequest, lf::a2a::v1::TaskPushNotificationConfig,
lf::a2a::v1::GetTaskPushNotificationConfigRequest, lf::a2a::v1::ListTaskPushNotificationConfigsRequest,
lf::a2a::v1::DeleteTaskPushNotificationConfigRequest>
lf::a2a::v1::DeleteTaskPushNotificationConfigRequest, lf::a2a::v1::GetExtendedAgentCardRequest>
payload = ListTasksRequest{};
};

using DispatchPayload = std::variant<lf::a2a::v1::SendMessageResponse, std::unique_ptr<ServerStreamSession>,
lf::a2a::v1::Task, ListTasksResponse, lf::a2a::v1::TaskPushNotificationConfig,
lf::a2a::v1::ListTaskPushNotificationConfigsResponse, std::monostate>;
using DispatchPayload =
std::variant<lf::a2a::v1::SendMessageResponse, std::unique_ptr<ServerStreamSession>, lf::a2a::v1::Task,
ListTasksResponse, lf::a2a::v1::TaskPushNotificationConfig,
lf::a2a::v1::ListTaskPushNotificationConfigsResponse, lf::a2a::v1::AgentCard, std::monostate>;

class DispatchResponse final {
public:
Expand All @@ -52,6 +54,8 @@ class DispatchResponse final {
explicit DispatchResponse(const lf::a2a::v1::TaskPushNotificationConfig& payload) : payload_(payload) {}
explicit DispatchResponse(lf::a2a::v1::TaskPushNotificationConfig&& payload) : payload_(std::move(payload)) {}
explicit DispatchResponse(const lf::a2a::v1::ListTaskPushNotificationConfigsResponse& payload) : payload_(payload) {}
explicit DispatchResponse(const lf::a2a::v1::AgentCard& payload) : payload_(payload) {}
explicit DispatchResponse(lf::a2a::v1::AgentCard&& payload) : payload_(std::move(payload)) {}
explicit DispatchResponse(lf::a2a::v1::ListTaskPushNotificationConfigsResponse&& payload)
: payload_(std::move(payload)) {}
DispatchResponse() : payload_(std::monostate{}) {}
Expand Down
5 changes: 5 additions & 0 deletions include/a2a/server/dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <shared_mutex>
#include <vector>

#include "a2a/core/agent_card/agent_card_provider.h"
#include "a2a/core/result.h"
#include "a2a/server/agent_executor.h"
#include "a2a/server/dispatch_types.h"
Expand All @@ -18,7 +19,10 @@ namespace a2a::server {
class Dispatcher final {
public:
explicit Dispatcher(AgentExecutor* executor);
explicit Dispatcher(AgentExecutor* executor, std::shared_ptr<core::AgentCardProvider> agent_card_provider);
explicit Dispatcher(AgentExecutor* executor, std::vector<std::shared_ptr<ServerInterceptor>> interceptors);
Dispatcher(AgentExecutor* executor, std::vector<std::shared_ptr<ServerInterceptor>> interceptors,
std::shared_ptr<core::AgentCardProvider> agent_card_provider);

[[nodiscard]] core::Result<DispatchResponse> Dispatch(const DispatchRequest& request, RequestContext& context) const;
void AddInterceptor(std::shared_ptr<ServerInterceptor> interceptor);
Expand All @@ -28,6 +32,7 @@ class Dispatcher final {
const core::Result<DispatchResponse>& result) const;

AgentExecutor* executor_ = nullptr;
std::shared_ptr<core::AgentCardProvider> agent_card_provider_;
mutable std::shared_mutex interceptor_mutex_;
std::vector<std::shared_ptr<ServerInterceptor>> interceptors_;
};
Expand Down
2 changes: 1 addition & 1 deletion include/a2a/server/grpc_server_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace a2a::server {

struct GrpcServerTransportOptions final {
std::vector<std::string> required_extensions;
std::vector<std::string> required_extensions = {};
};

class GrpcServerTransport final : public lf::a2a::v1::A2AService::Service {
Expand Down
2 changes: 1 addition & 1 deletion include/a2a/server/json_rpc_server_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct JsonRpcServerTransportOptions final {
bool require_version_header = true;
std::size_t default_list_tasks_page_size = 50;
std::size_t max_list_tasks_page_size = 100;
std::vector<std::string> required_extensions;
std::vector<std::string> required_extensions = {};
};

class JsonRpcServerTransport final {
Expand Down
6 changes: 5 additions & 1 deletion include/a2a/server/rest_server_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ struct RestServerTransportOptions final {
bool require_version_header = true;
bool include_legacy_transport_fields = true;
std::optional<AgentCardCacheSettings> agent_card_cache_settings;
std::vector<std::string> required_extensions;
std::vector<std::string> required_extensions = {};
};

class RestServerTransport final {
public:
static constexpr std::string_view kAgentCardPath = "/.well-known/agent-card.json";
static constexpr std::string_view kLegacyAgentCardPath = "/.well-known/agent.json";
static constexpr std::string_view kExtendedAgentCardPath = "/extendedAgentCard";

RestServerTransport(Dispatcher* dispatcher, lf::a2a::v1::AgentCard agent_card,
RestServerTransportOptions options = {});
Expand All @@ -63,11 +64,14 @@ class RestServerTransport final {
[[nodiscard]] core::Result<RestRequest> BuildRestRequest(const HttpServerRequest& request) const;
[[nodiscard]] core::Result<void> ValidateVersionHeader(const HttpServerRequest& request) const;
[[nodiscard]] core::Result<HttpServerResponse> HandleAgentCard(const HttpServerRequest& request) const;
[[nodiscard]] core::Result<HttpServerResponse> HandleExtendedAgentCard(const HttpServerRequest& request,
std::string_view tenant) const;
[[nodiscard]] static HttpServerResponse ToHttpResponse(const RestResponse& response,
const std::vector<std::string>& activated_extensions);

static std::string NormalizeBasePath(std::string_view path);

Dispatcher* dispatcher_ = nullptr;
RestTransport transport_;
lf::a2a::v1::AgentCard agent_card_;
RestServerTransportOptions options_;
Expand Down
5 changes: 2 additions & 3 deletions include/a2a/server/stores/postgres_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <vector>

#include "a2a/core/error.h"
#include "a2a/core/non_copyable.h"
#include "a2a/server/stores/store_factory.h"

typedef struct pg_conn PGconn;
Expand Down Expand Up @@ -55,11 +56,9 @@ class PostgresConnectionPool final {
public:
explicit PostgresConnectionPool(std::string connection_string, std::size_t size = kDefaultPostgresConnectionPoolSize);

class Lease final {
class Lease final : private core::NonCopyable {
public:
Lease(PostgresConnectionPool* pool, PgConnection connection);
Lease(const Lease&) = delete;
Lease& operator=(const Lease&) = delete;
Lease(Lease&& other) noexcept;
Lease& operator=(Lease&& other) noexcept = delete;
~Lease();
Expand Down
7 changes: 2 additions & 5 deletions include/a2a/server/stores/store_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <memory>
#include <string>

#include "a2a/core/non_copyable.h"
#include "a2a/core/result.h"
#include "a2a/server/push_notification_store.h"
#include "a2a/server/tasks/in_memory_task_store.h"
Expand All @@ -28,13 +29,9 @@ struct StoreBundle final {
std::unique_ptr<PushNotificationStore> push_store;
};

class StoreFactory {
class StoreFactory : private core::NonCopyableOrMovable {
public:
StoreFactory() = default;
StoreFactory(const StoreFactory&) = delete;
StoreFactory& operator=(const StoreFactory&) = delete;
StoreFactory(StoreFactory&&) = delete;
StoreFactory& operator=(StoreFactory&&) = delete;
virtual ~StoreFactory() = default;

[[nodiscard]] virtual StoreBackendKind backend_kind() const noexcept = 0;
Expand Down
6 changes: 2 additions & 4 deletions include/a2a/server/stream_response_coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
#include <optional>
#include <utility>

#include "a2a/core/non_copyable.h"
#include "a2a/v1/a2a.pb.h"

namespace a2a::server {

class StreamResponseCoroutine final {
class StreamResponseCoroutine final : private core::NonCopyable {
public:
struct promise_type final {
[[nodiscard]] StreamResponseCoroutine get_return_object() {
Expand All @@ -32,9 +33,6 @@ class StreamResponseCoroutine final {
};

StreamResponseCoroutine() = default;
StreamResponseCoroutine(const StreamResponseCoroutine&) = delete;
StreamResponseCoroutine& operator=(const StreamResponseCoroutine&) = delete;

StreamResponseCoroutine(StreamResponseCoroutine&& other) noexcept : handle_(std::exchange(other.handle_, {})) {}
StreamResponseCoroutine& operator=(StreamResponseCoroutine&& other) noexcept {
if (this != &other) {
Expand Down
Loading
Loading