Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
5c99468
Added generic client hooks for HTTP based authentication, and improve…
mprynce Jun 19, 2025
73983b2
Merge branch 'main' into feature-auth-hooks
mprynce Jun 23, 2025
1abc8a1
fix: setting context id in _createRequestContext (#49)
clriesco Jul 30, 2025
a4c4f74
chore: fix tests & run cmd (#80)
swapydapy Jul 30, 2025
c640caa
chore: Use npmjs registry for module resolutions (#82)
sks Jul 30, 2025
d1202c5
chore: run unit test on PRs (#81)
swapydapy Jul 30, 2025
dc92d32
feat: add support for custom agent card url. resolves #68 (#79)
kthota-g Jul 30, 2025
305dbef
chore(main): release 0.2.5 (#67)
release-please[bot] Jul 30, 2025
3bda04b
chore: fix npm publish workflow (#83)
swapydapy Jul 30, 2025
2984777
fix: mocha not able to detect tests (#86)
swapydapy Aug 3, 2025
60899c5
feat!: make Express dependency optional for edge environment compatib…
ajaynagotha Aug 3, 2025
b85c0e5
Added fetchImpl support and reworked options parameter
mprynce Aug 3, 2025
1360831
Merge branch 'main' into feature-auth-hooks
mprynce Aug 3, 2025
d9cadc3
Changed _fetch to _fetchRpc to make the difference in usage more clear
mprynce Aug 3, 2025
34aefd8
Merge branch 'feature-auth-hooks' of github.com:mprynce/a2a-js into f…
mprynce Aug 3, 2025
2aa97d8
Removed invalid import
mprynce Aug 3, 2025
9093779
Fixed failing tests
mprynce Aug 3, 2025
2ff20f7
First pass on client tests
mprynce Aug 3, 2025
730273f
More client auth tests
mprynce Aug 3, 2025
ae53da1
feat!: upgrade to a2a 0.3.0 spec version (#87)
swapydapy Aug 4, 2025
2e0dc21
Merge remote-tracking branch 'upstream/main' into feature-auth-hooks
mprynce Aug 4, 2025
46f2d86
Make error message test more flexible to handle test differences
mprynce Aug 4, 2025
654d674
ci: Update release-please to use GitHub Action (#90)
holtskinner Aug 5, 2025
b0ea294
ci: Add PAT to release-please (#91)
holtskinner Aug 5, 2025
f401309
Merge remote-tracking branch 'upstream/main' into feature-auth-hooks
mprynce Aug 5, 2025
c4ed9ee
Refactored exports from ./index.ts to client/index.ts and server/inde…
mprynce Aug 5, 2025
1007006
Better documentation for auth-handler and explanation for onSuccess
mprynce Aug 5, 2025
92a2c9b
chore(main): release 0.3.0 (#92)
a2a-bot Aug 5, 2025
5e96e49
Merge branch 'main' into feature-auth-hooks
mprynce Aug 5, 2025
19e0d75
chore: Add permission for npm provenance (#93)
swapydapy Aug 5, 2025
5151ada
Merge branch 'main' into feature-auth-hooks
mprynce Aug 5, 2025
4c6272f
Merge remote-tracking branch 'upstream/main' into feature-auth-hooks
mprynce Aug 5, 2025
fd30c50
docs: Add `protocolVersion` to agent card in readme (#95)
jedrazb Aug 6, 2025
8c40b9a
Merge branch 'main' into feature-auth-hooks
mprynce Aug 6, 2025
8e990e4
fix: add missing express entrypoint to tsup config (#96)
ajaynagotha Aug 6, 2025
1a5432d
chore(main): release 0.3.1 (#97)
a2a-bot Aug 6, 2025
118abae
chore: fix repository url in package.json (#98)
swapydapy Aug 6, 2025
f7bed7e
Big refactor to leverage fetchImpl instead of hard-wired Authenticati…
mprynce Aug 7, 2025
96a3fd4
Cleaned up loggin messages
mprynce Aug 7, 2025
20ffe7c
Properly use request ids in tests
mprynce Aug 7, 2025
88616fd
Merge remote-tracking branch 'upstream/main' into feature-auth-hooks
mprynce Aug 7, 2025
1be01d0
Removing older auth hooks and realigning with upstream/main
mprynce Aug 7, 2025
6d99e5e
Merge branch 'feature-auth-hooks' of github.com:mprynce/a2a-js into f…
mprynce Aug 7, 2025
d3865fa
Added linefeed at end of file
mprynce Aug 7, 2025
d70d251
Refactored code to extract message id, and fixed double read of body …
mprynce Aug 7, 2025
989847d
Refactoring and code cleanup
mprynce Aug 7, 2025
f15e301
Refactored mockAgentCard
mprynce Aug 7, 2025
720829b
Removed unecessary conversions
mprynce Aug 7, 2025
54ba442
Refactored the mockMessage and messageParams into reusable functions.…
mprynce Aug 7, 2025
98da88a
Rescoping of mockFetch to class
mprynce Aug 7, 2025
c44f084
Exported A2AClientOptions
mprynce Aug 7, 2025
9443f61
Cleaned up extraneous error logs
mprynce Aug 7, 2025
37d9374
ci: Add Conventional Commits Action (#103)
holtskinner Aug 8, 2025
a27e714
Renamed onSuccess to onSuccessfulRetry and made optional, improved do…
mprynce Aug 11, 2025
214124f
Merge branch 'main' into feature-auth-hooks
mprynce Aug 11, 2025
2ae955e
Improved shouldRetryWithHeaders() docs
mprynce Aug 11, 2025
94e37fa
Merge remote-tracking branch 'upstream/main' into feature-auth-hooks
mprynce Aug 11, 2025
3009080
Merge branch 'feature-auth-hooks' of github.com:mprynce/a2a-js into f…
mprynce Aug 11, 2025
3a0f1d0
fix: fix Incorrect Well-Known Path for Agent Card (#102)
ronantakizawa Aug 11, 2025
7ba0da2
Converted AuthHandlingFetch to HOC with createAuthenticatingFetchWith…
mprynce Aug 11, 2025
3635d0d
Removed defensive code that is not currently needed
mprynce Aug 11, 2025
81bc9ef
Removed test reset and fixed call count to 1
mprynce Aug 11, 2025
f8b594e
Removed Request ID management test
mprynce Aug 11, 2025
300af3d
Reverted changes
mprynce Aug 11, 2025
6a488c5
Removed minor soak test
mprynce Aug 11, 2025
59ca7ae
Removed WWW-Authenticate test
mprynce Aug 11, 2025
176323f
Removed overlapping tests between client and client_auth
mprynce Aug 11, 2025
508d342
Removed overlapping tests
mprynce Aug 11, 2025
5eddec3
Fixed LLM test creation fail
mprynce Aug 11, 2025
d7a3af1
Merge branch 'main' into feature-auth-hooks
mprynce Aug 11, 2025
c33fd42
Updated tests to new agent card path
mprynce Aug 11, 2025
41ffbea
Use a mock fetch to avoid real HTTP requests during testing
mprynce Aug 11, 2025
97dc7ee
Removed specific example of Agentic JWT auth and replaced with genera…
mprynce Aug 17, 2025
3375c2e
Removed notes about transient headers that are described in the onSuc…
mprynce Aug 17, 2025
46dc43a
Revised to suggested wording
mprynce Aug 17, 2025
8a27221
Removed unecessry second createFreshMockFetch, and removed use of Rea…
mprynce Aug 17, 2025
809e739
Removed unecessary ReadableStream
mprynce Aug 17, 2025
4f69af0
Fixed header merge test
mprynce Aug 17, 2025
eaa00d1
Removed redundant Authentication Retry Logic tests
mprynce Aug 17, 2025
7db7860
Removed Integration with A2AClient test
mprynce Aug 17, 2025
3b14771
Updated to use existing mockFetch
mprynce Aug 17, 2025
fc85d58
Made the WWW-Authenticate test much more general and less spcific - s…
mprynce Aug 17, 2025
fd85e77
Simplified code while retaining defensive code. Updated test to verif…
mprynce Aug 17, 2025
c96b983
Removed Authorization header scheme and token verification from tests
mprynce Aug 17, 2025
5d83c7d
Revised the test authorization schemes from Agentic to Bearer to bett…
mprynce Aug 17, 2025
0b08e5d
Removed reset() and revised call counts
mprynce Aug 17, 2025
b1fe5e8
Big refactor of createMockFetch() to reduce redundant code
mprynce Aug 17, 2025
a5347fd
Renamed client test to recommended text
mprynce Aug 17, 2025
2ff36a1
Renamed noAuthHandlerFetch to fetchWithApiError
mprynce Aug 17, 2025
4aa7baa
Update import in index.ts
swapydapy Aug 17, 2025
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: 0 additions & 2 deletions .github/conventional-commit-lint.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/release-please.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/release-trigger.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Conventional Commits"

on:
pull_request:
types:
- opened
- edited
- synchronize

permissions:
contents: read

jobs:
main:
permissions:
pull-requests: read
statuses: write
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- name: semantic-pull-request
uses: amannn/action-semantic-pull-request@v5.5.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: false
23 changes: 10 additions & 13 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package
name: Publish to NPM

on:
release:
types: [created]

jobs:
build:
publish-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- run: npm ci
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm run build

# Now configure with the publish service for install.
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 18
registry-url: 'https://wombat-dressing-room.appspot.com/'
- run: npm ci
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
19 changes: 19 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

name: release-please

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.A2A_BOT_PAT }}
release-type: node
25 changes: 25 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Run Unit Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- run: npm ci
- run: npm test
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# Changelog

## [0.3.1](https://github.com/a2aproject/a2a-js/compare/v0.3.0...v0.3.1) (2025-08-06)


### Bug Fixes

* add missing express entrypoint to tsup config ([#96](https://github.com/a2aproject/a2a-js/issues/96)) ([8e990e4](https://github.com/a2aproject/a2a-js/commit/8e990e497927e3554699f8ebb005829b170d9bc3))

## [0.3.0](https://github.com/a2aproject/a2a-js/compare/v0.2.5...v0.3.0) (2025-08-05)


### ⚠ BREAKING CHANGES

* upgrade to a2a 0.3.0 spec version ([#87](https://github.com/a2aproject/a2a-js/issues/87))
* make Express dependency optional

### Features

* make Express dependency optional ([60899c5](https://github.com/a2aproject/a2a-js/commit/60899c51e2910570402d1207f6b50952bed8862f))
* upgrade to a2a 0.3.0 spec version ([#87](https://github.com/a2aproject/a2a-js/issues/87)) ([ae53da1](https://github.com/a2aproject/a2a-js/commit/ae53da1e36ff58912e01fefa854c5b3174edf7d8))

## [0.2.5](https://github.com/a2aproject/a2a-js/compare/v0.2.4...v0.2.5) (2025-07-30)


### Features

* add support for custom agent card url. resolves [#68](https://github.com/a2aproject/a2a-js/issues/68) ([#79](https://github.com/a2aproject/a2a-js/issues/79)) ([dc92d32](https://github.com/a2aproject/a2a-js/commit/dc92d321ac7c142ff5232cdca0db8a24b4d76da0))
* Export ExecutionEventQueue in server ([#61](https://github.com/a2aproject/a2a-js/issues/61)) ([530c0b9](https://github.com/a2aproject/a2a-js/commit/530c0b9f1fd50fafd991f640c119837860ae8c3f))
* Export type AgentExecutionEvent ([#66](https://github.com/a2aproject/a2a-js/issues/66)) ([f4c81f4](https://github.com/a2aproject/a2a-js/commit/f4c81f41866c24d83823b5db7d24b5fdb56b37b4))


### Bug Fixes

* correct the example code ([#64](https://github.com/a2aproject/a2a-js/issues/64)) ([126eee4](https://github.com/a2aproject/a2a-js/commit/126eee4e3b79e9475a5af5cbebb0e98b68f286fa))
* setting context id in _createRequestContext ([#49](https://github.com/a2aproject/a2a-js/issues/49)) ([1abc8a1](https://github.com/a2aproject/a2a-js/commit/1abc8a1f3590f78647d94c5a1e31444203e1131f))

## [0.2.4](https://github.com/a2aproject/a2a-js/compare/v0.2.3...v0.2.4) (2025-07-14)


Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,25 @@ You can install the A2A SDK using either `npm`.
npm install @a2a-js/sdk
```

### For Server Usage

If you plan to use the A2A server functionality (A2AExpressApp), you'll also need to install Express as it's a peer dependency:

```bash
npm install express
```

You can also find JavaScript samples [here](https://github.com/google-a2a/a2a-samples/tree/main/samples/js).

## A2A Server

This directory contains a TypeScript server implementation for the Agent-to-Agent (A2A) communication protocol, built using Express.js.

**Note:** Express is a peer dependency for server functionality. Make sure to install it separately:
```bash
npm install express
```

### 1. Define Agent Card

```typescript
Expand All @@ -42,6 +55,7 @@ const movieAgentCard: AgentCard = {
organization: "A2A Agents",
url: "https://example.com/a2a-agents", // Added provider URL
},
protocolVersion: "0.3.0", // A2A protocol this agent supports.
version: "0.0.2", // Incremented version
capabilities: {
streaming: true, // Supports streaming
Expand Down Expand Up @@ -81,12 +95,12 @@ const movieAgentCard: AgentCard = {
import {
InMemoryTaskStore,
TaskStore,
A2AExpressApp,
AgentExecutor,
RequestContext,
ExecutionEventBus,
DefaultRequestHandler,
} from "@a2a-js/sdk/server";
import { A2AExpressApp } from "@a2a-js/sdk/server/express";

// 1. Define your agent's logic as a AgentExecutor
class MyAgentExecutor implements AgentExecutor {
Expand Down Expand Up @@ -234,7 +248,7 @@ expressApp.listen(PORT, () => {
`[MyAgent] Server using new framework started on http://localhost:${PORT}`
);
console.log(
`[MyAgent] Agent Card: http://localhost:${PORT}/.well-known/agent.json`
`[MyAgent] Agent Card: http://localhost:${PORT}/.well-known/agent-card.json`
);
console.log("[MyAgent] Press Ctrl+C to stop the server");
});
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 24 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"name": "@a2a-js/sdk",
"version": "0.2.4",
"version": "0.3.1",
"description": "Server & Client SDK for Agent2Agent protocol",
"repository": "google-a2a/a2a-js.git",
"repository": {
"type": "git",
"url": "git+https://github.com/a2aproject/a2a-js.git"
},
"engines": {
"node": ">=18"
},
Expand All @@ -20,6 +23,11 @@
"import": "./dist/server/index.js",
"require": "./dist/server/index.cjs"
},
"./server/express": {
"types": "./dist/server/express/index.d.ts",
"import": "./dist/server/express/index.js",
"require": "./dist/server/express/index.cjs"
},
"./client": {
"types": "./dist/client/index.d.ts",
"import": "./dist/client/index.js",
Expand All @@ -35,11 +43,13 @@
"@genkit-ai/googleai": "^1.8.0",
"@genkit-ai/vertexai": "^1.8.0",
"@types/chai": "^5.2.2",
"@types/express": "^4.17.23",
"@types/mocha": "^10.0.10",
"@types/node": "^22.13.14",
"@types/sinon": "^17.0.4",
"c8": "^10.1.3",
"chai": "^5.2.0",
"express": "^4.21.2",
"genkit": "^1.8.0",
"gts": "^6.0.2",
"json-schema-to-typescript": "^15.0.4",
Expand All @@ -53,18 +63,24 @@
"clean": "gts clean",
"build": "tsup",
"pretest": "npm run build",
"test": "mocha build/test/**/*.js",
"test": "mocha test/**/*.spec.ts",
"coverage": "c8 npm run test",
"generate": "curl https://raw.githubusercontent.com/google-a2a/A2A/refs/heads/main/specification/json/a2a.json > spec.json && node scripts/generateTypes.js && rm spec.json",
"sample:cli": "tsx src/samples/cli.ts",
"sample:movie-agent": "tsx src/samples/agents/movie-agent/index.ts"
},
"dependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^4.17.23",
"body-parser": "^2.2.0",
"cors": "^2.8.5",
"express": "^4.21.2",
"uuid": "^11.1.0"
},
"peerDependencies": {
"express": "^4.21.2"
},
"peerDependenciesMeta": {
"express": {
"optional": true
}
},
"mocha": {
"require": "tsx"
}
}
5 changes: 4 additions & 1 deletion src/a2a_response.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SendMessageResponse, SendStreamingMessageResponse, GetTaskResponse, CancelTaskResponse, SetTaskPushNotificationConfigResponse, GetTaskPushNotificationConfigResponse, JSONRPCErrorResponse } from "./types.js";
import { SendMessageResponse, SendStreamingMessageResponse, GetTaskResponse, CancelTaskResponse, SetTaskPushNotificationConfigResponse, GetTaskPushNotificationConfigResponse, JSONRPCErrorResponse, ListTaskPushNotificationConfigSuccessResponse, DeleteTaskPushNotificationConfigSuccessResponse, GetAuthenticatedExtendedCardSuccessResponse } from "./types.js";

/**
* Represents any valid JSON-RPC response defined in the A2A protocol.
Expand All @@ -10,5 +10,8 @@ export type A2AResponse =
| CancelTaskResponse
| SetTaskPushNotificationConfigResponse
| GetTaskPushNotificationConfigResponse
| ListTaskPushNotificationConfigSuccessResponse
| DeleteTaskPushNotificationConfigSuccessResponse
| GetAuthenticatedExtendedCardSuccessResponse
| JSONRPCErrorResponse; // Catch-all for other error responses

Loading