-
-
Notifications
You must be signed in to change notification settings - Fork 827
fix: correct A2A agent card URLs #1199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| "@voltagent/a2a-server": patch | ||
| "@voltagent/server-core": patch | ||
| "@voltagent/server-hono": patch | ||
| "@voltagent/server-elysia": patch | ||
| --- | ||
|
|
||
| fix: point A2A agent cards at the JSON-RPC endpoint | ||
|
|
||
| A2A agent cards now advertise `/a2a/{serverId}` instead of the internal | ||
| `/.well-known/{serverId}/agent-card.json` discovery document. When the card is | ||
| served through the Hono or Elysia integrations, VoltAgent also resolves that | ||
| endpoint to an absolute URL based on the incoming request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { buildA2AEndpointPath, buildAgentCardPath } from "./routes"; | ||
|
|
||
| describe("A2A route helpers", () => { | ||
| it("encodes reserved characters without removing internal spaces", () => { | ||
| expect(buildA2AEndpointPath("support agent/ops?")).toBe("/a2a/support%20agent%2Fops%3F"); | ||
| expect(buildAgentCardPath("support agent/ops?")).toBe( | ||
| "/.well-known/support%20agent%2Fops%3F/agent-card.json", | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| import { A2AServerRegistry, type ServerProviderDeps, TriggerRegistry } from "@voltagent/core"; | ||
| import type { Logger } from "@voltagent/internal"; | ||
| import * as serverCore from "@voltagent/server-core"; | ||
| import { beforeEach, describe, expect, it, vi } from "vitest"; | ||
| import { OpenAPIHono } from "../zod-openapi-compat"; | ||
| import { registerA2ARoutes } from "./a2a.routes"; | ||
|
|
||
| vi.mock("@voltagent/server-core", async () => { | ||
| const actual = await vi.importActual("@voltagent/server-core"); | ||
| return { | ||
| ...actual, | ||
| executeA2ARequest: vi.fn(), | ||
| resolveAgentCard: vi.fn(), | ||
| A2A_ROUTES: actual.A2A_ROUTES, | ||
| }; | ||
| }); | ||
|
|
||
| vi.mock("@voltagent/a2a-server", async () => { | ||
| return { | ||
| normalizeError: vi.fn().mockImplementation((id, error) => ({ | ||
| jsonrpc: "2.0", | ||
| id, | ||
| error: { | ||
| code: error.code || -32603, | ||
| message: error.message, | ||
| }, | ||
| })), | ||
| }; | ||
| }); | ||
|
|
||
| function createMockA2ARegistry() { | ||
| const registry = new A2AServerRegistry(); | ||
| registry.register( | ||
| { | ||
| getMetadata() { | ||
| return { | ||
| id: "server1", | ||
| name: "server1", | ||
| version: "1.0.0", | ||
| }; | ||
| }, | ||
| }, | ||
| { | ||
| agentRegistry: { | ||
| getAgent() { | ||
| return undefined; | ||
| }, | ||
| getAllAgents() { | ||
| return []; | ||
| }, | ||
| }, | ||
| }, | ||
| ); | ||
| return registry; | ||
| } | ||
|
|
||
| function createMockDeps(): ServerProviderDeps { | ||
| return { | ||
| agentRegistry: { | ||
| getAgent() { | ||
| return undefined; | ||
| }, | ||
| getAllAgents() { | ||
| return []; | ||
| }, | ||
| getAgentCount() { | ||
| return 0; | ||
| }, | ||
| removeAgent() { | ||
| return false; | ||
| }, | ||
| registerAgent() {}, | ||
| getGlobalVoltOpsClient() { | ||
| return undefined; | ||
| }, | ||
| getGlobalLogger() { | ||
| return undefined; | ||
| }, | ||
| }, | ||
| workflowRegistry: { | ||
| getWorkflow() { | ||
| return undefined; | ||
| }, | ||
| getWorkflowsForApi() { | ||
| return []; | ||
| }, | ||
| getWorkflowDetailForApi() { | ||
| return undefined; | ||
| }, | ||
| getWorkflowCount() { | ||
| return 0; | ||
| }, | ||
| getAllWorkflowIds() { | ||
| return []; | ||
| }, | ||
| on() {}, | ||
| off() {}, | ||
| activeExecutions: new Map(), | ||
| async resumeSuspendedWorkflow() { | ||
| return undefined; | ||
| }, | ||
| }, | ||
| triggerRegistry: new TriggerRegistry(), | ||
| a2a: { | ||
| registry: createMockA2ARegistry(), | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| function createMockLogger(): Logger { | ||
| const logger: Logger = { | ||
| trace: vi.fn(), | ||
| debug: vi.fn(), | ||
| info: vi.fn(), | ||
| warn: vi.fn(), | ||
| error: vi.fn(), | ||
| fatal: vi.fn(), | ||
| child: vi.fn(() => logger), | ||
| }; | ||
|
|
||
| return logger; | ||
| } | ||
|
|
||
| describe("A2A Routes", () => { | ||
| let app: InstanceType<typeof OpenAPIHono>; | ||
| let mockDeps: ServerProviderDeps; | ||
| let mockLogger: Logger; | ||
|
|
||
| beforeEach(() => { | ||
| app = new OpenAPIHono(); | ||
| mockDeps = createMockDeps(); | ||
| mockLogger = createMockLogger(); | ||
| registerA2ARoutes(app, mockDeps, mockLogger); | ||
| vi.clearAllMocks(); | ||
| }); | ||
|
|
||
| it("passes the request URL when resolving the agent card", async () => { | ||
| const card = { | ||
| name: "agent", | ||
| description: "desc", | ||
| url: "https://agents.example/a2a/server1", | ||
| version: "1.0.0", | ||
| capabilities: { | ||
| streaming: true, | ||
| pushNotifications: false, | ||
| stateTransitionHistory: false, | ||
| }, | ||
| defaultInputModes: ["text"], | ||
| defaultOutputModes: ["text"], | ||
| skills: [], | ||
| }; | ||
| vi.mocked(serverCore.resolveAgentCard).mockReturnValue(card); | ||
|
|
||
| const requestUrl = "http://agents.example/.well-known/server1/agent-card.json"; | ||
| const response = await app.request(requestUrl); | ||
|
|
||
| expect(response.status).toBe(200); | ||
| expect(await response.json()).toEqual(card); | ||
| expect(serverCore.resolveAgentCard).toHaveBeenCalledWith( | ||
| mockDeps.a2a?.registry, | ||
| "server1", | ||
| "server1", | ||
| { requestUrl }, | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.