Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 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
7214233
docs: remove Conan packaging notes
MisterVVP Jul 2, 2026
af90825
fix: tune bm threshold
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
60 changes: 60 additions & 0 deletions include/a2a/core/agent_card/agent_card_builder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 Vladimir Pavlov <mistervvp@outlook.com> (https://github.com/MisterVVP)

#pragma once

#include <string>
#include <string_view>

#include "a2a/core/error.h"
#include "a2a/core/protocol_bindings.h"
#include "a2a/core/result.h"
#include "a2a/core/version.h"
#include "a2a/v1/a2a.pb.h"

namespace a2a::core {

class AgentCardBuilder final {
public:
AgentCardBuilder& SetName(std::string_view name);
AgentCardBuilder& SetVersion(std::string_view version);
AgentCardBuilder& SetDescription(std::string_view description);
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 {
std::string_view binding;
std::string_view version;
std::string_view url;
};

AgentCardBuilder& AddInterface(const InterfaceSpec& spec);

[[nodiscard]] Result<void> Validate() const;
[[nodiscard]] lf::a2a::v1::AgentCard Build() const;

[[nodiscard]] static AgentCardBuilder RestPreset(std::string_view name, std::string_view url,
std::string_view version = Version::kAgentCardVersion);
[[nodiscard]] static AgentCardBuilder JsonRpcPreset(std::string_view name, std::string_view url,
std::string_view version = Version::kAgentCardVersion);
[[nodiscard]] static AgentCardBuilder GrpcPreset(std::string_view name, std::string_view url,
std::string_view version = Version::kAgentCardVersion);
struct ConformancePresetSpec final {
std::string_view rest_url;
std::string_view json_rpc_url;
std::string_view grpc_url;
};

[[nodiscard]] static AgentCardBuilder ConformancePreset(const ConformancePresetSpec& spec,
std::string_view name = "Conformance SUT",
std::string_view version = Version::kAgentCardVersion,
std::string_view description = "A2A conformance agent");

private:
lf::a2a::v1::AgentCard card_;
};

} // namespace a2a::core
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
55 changes: 1 addition & 54 deletions include/a2a/core/agent_card_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,4 @@

#pragma once

#include <string>
#include <string_view>

#include "a2a/core/error.h"
#include "a2a/core/protocol_bindings.h"
#include "a2a/core/result.h"
#include "a2a/core/version.h"
#include "a2a/v1/a2a.pb.h"

namespace a2a::core {

class AgentCardBuilder final {
public:
AgentCardBuilder& SetName(std::string_view name);
AgentCardBuilder& SetVersion(std::string_view version);
AgentCardBuilder& SetDescription(std::string_view description);
AgentCardBuilder& AddDefaultInputMode(std::string_view mode);
AgentCardBuilder& AddDefaultOutputMode(std::string_view mode);
AgentCardBuilder& WithPushNotifications(bool enabled);
AgentCardBuilder& AddExtension(std::string_view uri, bool required, std::string_view description = {});

struct InterfaceSpec final {
std::string_view binding;
std::string_view version;
std::string_view url;
};

AgentCardBuilder& AddInterface(const InterfaceSpec& spec);

[[nodiscard]] Result<void> Validate() const;
[[nodiscard]] lf::a2a::v1::AgentCard Build() const;

[[nodiscard]] static AgentCardBuilder RestPreset(std::string_view name, std::string_view url,
std::string_view version = Version::kAgentCardVersion);
[[nodiscard]] static AgentCardBuilder JsonRpcPreset(std::string_view name, std::string_view url,
std::string_view version = Version::kAgentCardVersion);
[[nodiscard]] static AgentCardBuilder GrpcPreset(std::string_view name, std::string_view url,
std::string_view version = Version::kAgentCardVersion);
struct ConformancePresetSpec final {
std::string_view rest_url;
std::string_view json_rpc_url;
std::string_view grpc_url;
};

[[nodiscard]] static AgentCardBuilder ConformancePreset(const ConformancePresetSpec& spec,
std::string_view name = "Conformance SUT",
std::string_view version = Version::kAgentCardVersion,
std::string_view description = "A2A conformance agent");

private:
lf::a2a::v1::AgentCard card_;
};

} // namespace a2a::core
#include "a2a/core/agent_card/agent_card_builder.h"
Comment thread
MisterVVP marked this conversation as resolved.
Outdated
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
1 change: 1 addition & 0 deletions include/a2a/core/http_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ inline constexpr char kContentTypeParameterSeparator = ';';

inline constexpr std::string_view kMethodGet = "GET";
inline constexpr std::string_view kMethodPost = "POST";
inline constexpr std::string_view kMethodDelete = "DELETE";

inline constexpr std::string_view kHttpScheme = "http://";
inline constexpr std::string_view kHttpsScheme = "https://";
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
18 changes: 18 additions & 0 deletions include/a2a/core/protocol_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,22 @@ inline constexpr std::string_view kListTaskPushNotificationConfigs = "ListTaskPu
inline constexpr std::string_view kDeleteTaskPushNotificationConfig = "DeleteTaskPushNotificationConfig";
inline constexpr std::string_view kPushNotificationConfigsSegment = "/pushNotificationConfigs";

struct GetExtendedAgentCardMethodName final {
static constexpr std::string_view kCanonical = "GetExtendedAgentCard";
static constexpr std::string_view kJsonRpcAlias = "a2a.getExtendedAgentCard";

constexpr operator std::string_view() const noexcept { return kCanonical; }
};

inline constexpr GetExtendedAgentCardMethodName kGetExtendedAgentCard{};

constexpr bool operator==(std::string_view actual, GetExtendedAgentCardMethodName) noexcept {
return actual == GetExtendedAgentCardMethodName::kCanonical ||
actual == GetExtendedAgentCardMethodName::kJsonRpcAlias;
}

constexpr bool operator==(GetExtendedAgentCardMethodName method, std::string_view actual) noexcept {
return actual == method;
}

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

#pragma once

#include <string_view>

namespace a2a::core::protocol_paths {

inline constexpr std::string_view kAgentCard = "/.well-known/agent-card.json";
inline constexpr std::string_view kLegacyAgentCard = "/.well-known/agent.json";
inline constexpr std::string_view kExtendedAgentCard = "/extendedAgentCard";
inline constexpr std::string_view kWellKnownPrefix = "/.well-known/";

} // namespace a2a::core::protocol_paths
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
Loading
Loading