a2a

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package a2a is Harbor's southbound A2A integration with the tool catalog (Phase 29). It implements `tools.ToolProvider` by composing the wire `distributed.RemoteTransport` (`internal/distributed/drivers/a2a`) with the catalog's standard `RunWithPolicyHooked` shell.

Discovery model. The Provider is parameterised by a single peer's base URL plus a wire `distributed.RemoteTransport` instance. At `Connect`, the Provider issues a `GetExtendedAgentCard` against the peer; `Discover` materialises each `AgentSkill` from the card into a `tools.ToolDescriptor` with `Transport: TransportA2A` and an Invoke closure that translates the catalog-edge JSON-RawMessage into an A2A `Message` with a `TextPart`, dispatches via the transport, and returns the resulting `a2a.Task` as the `ToolResult.Value`.

One Provider per peer. Operators wanting to register N peers instantiate N Providers; the catalog presents the union as one set of `Tool`s. The `SourceID` is derived from the peer URL so observability + audit can attribute each tool to its origin.

Reliability shell (D-024). Every Invoke routes through `tools.RunWithPolicyHooked` so timeout / retry / validation happen once, in the same place, regardless of transport. The wire driver does NOT add its own shell.

Concurrent reuse (D-025). Provider is constructed once with an immutable peer URL + transport reference; Connect / Discover / Close take an internal Mutex so concurrent calls are serialised; Invoke is stateless on the Provider and dispatches through the shared transport.

Index

Constants

View Source
const DriverName = "a2a"

DriverName documents the conceptual driver identifier. The tools subsystem has no driver-factory registry (catalogs are constructed in code), so this constant is for documentation + audit logging.

Variables

View Source
var (
	// ErrNotConnected — Discover or invocation called before Connect.
	ErrNotConnected = errors.New("tools/a2a: provider not connected")
	// ErrAgentSkillEmpty — discovered card declared zero skills.
	ErrAgentSkillEmpty = errors.New("tools/a2a: AgentCard declares no skills")
)

Sentinels.

Functions

This section is empty.

Types

type Option

type Option func(*config)

Option configures a Provider at construction.

func WithDescriptorOptions

func WithDescriptorOptions(opts ...tools.DescriptorOption) Option

WithDescriptorOptions injects per-skill descriptor options applied to every materialised Tool. Use this to override the policy shell (e.g. tighter timeouts for chatty peers) or to add audit tags.

func WithToolNamePrefix

func WithToolNamePrefix(prefix string) Option

WithToolNamePrefix prepends prefix + "." to every materialised tool's Name. The default is the peer URL's host (so two peers can expose a skill named "echo" without colliding).

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements `tools.ToolProvider` for a single A2A peer.

func New

func New(peerURL string, transport distributed.RemoteTransport, opts ...Option) (*Provider, error)

New constructs a Provider. `peerURL` is the peer's canonical base URL (matches a registered peer on the wire transport's Registry); `transport` is the wire `distributed.RemoteTransport`.

Returns an error when peerURL is empty or transport is nil — the Provider is unusable in either case.

func (*Provider) Close

func (p *Provider) Close(_ context.Context) error

Close is a no-op: the Provider does not own the transport (the caller does). Multiple Closes are safe.

func (*Provider) Connect

func (p *Provider) Connect(ctx context.Context) error

Connect fetches the AgentCard via the wire transport's `GetExtendedAgentCard`. Identity is read from ctx and propagated through the wire driver.

Connect is idempotent: a second call refreshes the cached card so callers can use Connect as a "manual cache invalidation" hook.

func (*Provider) Discover

func (p *Provider) Discover(_ context.Context) ([]tools.ToolDescriptor, error)

Discover returns one ToolDescriptor per `AgentSkill` on the cached AgentCard. Returns ErrNotConnected when Connect has not run; ErrAgentSkillEmpty when the card lists no skills.

func (*Provider) SourceID

func (p *Provider) SourceID() tools.ToolSourceID

SourceID returns the stable per-peer identifier surfaced on every materialised Tool.Source.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL