Skip to content

Commit 11caf1d

Browse files
committed
feat: Add support for A2A V3.0
Signed-off-by: jdiaconu <jdiaconu@cisco.com>
1 parent 319e12a commit 11caf1d

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

backend/internal/core/badge/a2a/discover.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ import (
88
"errors"
99
"io"
1010
"net/http"
11+
"regexp"
1112
"strings"
1213

1314
"github.com/outshift/identity-service/internal/pkg/httputil"
1415
"github.com/outshift/identity-service/pkg/log"
1516
)
1617

17-
const wellKnownUrlSuffix = "/.well-known/agent.json"
18+
const (
19+
wellKnownMatcher = `/.well-known/.*\.json$`
20+
wellKnownUrlSuffixV3 = "/.well-known/agent-card.json"
21+
)
1822

1923
// The discoverClient interface defines the core methods for discovering a deployed A2A agent
2024
type DiscoveryClient interface {
@@ -37,9 +41,10 @@ func (d *discoveryClient) Discover(
3741
ctx context.Context,
3842
wellKnownUrl string,
3943
) (string, error) {
40-
// validate the well-known URL
41-
if !strings.HasSuffix(wellKnownUrl, wellKnownUrlSuffix) {
42-
wellKnownUrl = strings.TrimSuffix(wellKnownUrl, "/") + wellKnownUrlSuffix
44+
// Check if the well-known URL ends with .json, if not, append the default V3 suffix
45+
var wellKnownUrlRegex = regexp.MustCompile(wellKnownMatcher)
46+
if !wellKnownUrlRegex.MatchString(wellKnownUrl) {
47+
wellKnownUrl = strings.TrimSuffix(wellKnownUrl, "/") + wellKnownUrlSuffixV3
4348
}
4449

4550
log.Debug("Using well-known URL for agent discovery: ", wellKnownUrl)

0 commit comments

Comments
 (0)