90 Commits

Author SHA1 Message Date
Guglielmo Colombo
bd4caa22a0
feat: implement GRPC server (#279)
# Description

This Pull Request implements server-side support for the gRPC transport
protocol.

**Schema and Generation**
The implementation is based on [A2A Proto Specification
v3.0.0](https://raw.githubusercontent.com/a2aproject/A2A/v0.3.0/specification/grpc/a2a.proto).

**Tooling**
ts-proto was adopted for generating TypeScript service definitions (with
buf), which will reuse the message types previously generated (this
requires a manual modification of the generated file).

**Limitations**
Due to the current dependency on Proto v3.0.0, the gRPC implementation
is missing some APIs already available for other transports, for example
the `getExtendedAuthenticatedAgentCard` method.
These missing endpoints will be implemented with future official
releases of proto specification.

**Entry Points**
A new dedicated entry point has been introduced to export the gRPC
server logic and @grpc/grpc-js and its related transport libraries have
been added as peer dependencies.

Fixes #275  🦕

Release-As: 0.3.9

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Ivan Shymko <ishymko@google.com>
Co-authored-by: Ivan Shymko <vana.shimko@gmail.com>
2026-01-15 13:56:11 +01:00
Ivan Shymko
45c0342f1d
docs: use artifact to deliver execution result in sample-agent (#297)
# Description

According to the
https://github.com/a2aproject/A2A/issues/822#issuecomment-3084892313 do
not use `TaskStatusUpdateEvent`'s to deliver agent execution results,
use `TaskArtifactUpdateEvent`'s instead:

<img width="1343" height="448" alt="Screenshot 2026-01-14 at 15 42 59"
src="https://github.com/user-attachments/assets/fc259512-3016-4a1d-84cc-d8e89b35669f"
/>
2026-01-14 16:29:29 +01:00
Guglielmo Colombo
d2efc4cf34
fix!: use ProtoJSON for REST transport (#292)
# Description

This PR resolves an incompatibility in the payload shape between the
REST Transport handlers and other A2A SDKs.

In this version, the transmitted payload now aligns with the field names
and structure defined in the proto file. A new `a2a.ts` file has been
introduced to represent the proto types, including their corresponding
`fromJson` and `toJson` conversion functions.

**Technically this is a breaking change, however current implementation
isn't compatible with other official SDKs, so fixing in-place.** Current
situation with JSON format for HTTP+JSON is complicated as there is no
explicit specification in 0.3, see
[here](https://github.com/a2aproject/a2a-js/issues/291#issuecomment-3719125908)
for more details.

Fixes #291  🦕

Release-As: 0.3.8

---------

Co-authored-by: Ivan Shymko <ishymko@google.com>
2026-01-13 17:08:15 +00:00
Ivan Shymko
eb604acc79
docs: support A2A agent on Agent Engine in samples/cli (#293)
# Description

Add `--agent-engine` parameter to the test CLI to add ADC authentication
used for Agent Engine deployed instances. It is required for both agent
card fetching (which requires auth as there is no public well-known
endpoint exposed) and other client calls.

Adding this for proper E2E manual testing of the mentioned issue and the
fix.

With current REST implementation it's not going to work with Agent
Engine instances (as per #291), this PR was tested on a WIP fix #292
against a "hello world" agent from
[here](b814aabd12/vertexai/preview/reasoning_engines/templates/a2a.py (L114))
deployed on Agent Engine:

```
npm run a2a:cli -- https://us-central1-aiplatform.googleapis.com/v1beta1/projects/XXX/locations/us-central1/reasoningEngines/XXX/ --agent-engine

> a2a:cli
> tsx cli.ts https://us-central1-aiplatform.googleapis.com/v1beta1/projects/XXX/locations/us-central1/reasoningEngines/XXX/ --agent-engine

A2A Terminal Client
Agent Base URL: https://us-central1-aiplatform.googleapis.com/v1beta1/projects/XXX/locations/us-central1/reasoningEngines/XXX/
Attempting to fetch agent card from agent at: https://us-central1-aiplatform.googleapis.com/v1beta1/projects/XXX/locations/us-central1/reasoningEngines/XXX/
✓ Agent Card Found:
  Name:        Hello World Agent
  Description: Just a hello world agent
  Version:     1.0.0
  Streaming:   Not Supported (or not specified)
No active task or context initially. Use '/new' to start a fresh session or send a message.
Enter messages, or use '/new' to start a new session. '/exit' to quit.
Hello World Agent > You: test
Sending message...

Hello World Agent [11:24:36 AM]: ✉️ Message Stream Event:
  Part 1: 📝 Text: Hello World
--- End of response stream for this input ---
Hello World Agent > You: 
```


Re #291, #292
2026-01-12 14:02:42 +01:00
dependabot[bot]
aaea98e1eb
chore(deps): bump qs, body-parser and express in /src/samples (#285)
Bumps [qs](https://github.com/ljharb/qs),
[body-parser](https://github.com/expressjs/body-parser) and
[express](https://github.com/expressjs/express). These dependencies
needed to be updated together.
Updates `qs` from 6.14.0 to 6.14.1
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/ljharb/qs/blob/main/CHANGELOG.md">qs's
changelog</a>.</em></p>
<blockquote>
<h2><strong>6.14.1</strong></h2>
<ul>
<li>[Fix] ensure arrayLength applies to <code>[]</code> notation as
well</li>
<li>[Fix] <code>parse</code>: when a custom decoder returns
<code>null</code> for a key, ignore that key</li>
<li>[Refactor] <code>parse</code>: extract key segment splitting
helper</li>
<li>[meta] add threat model</li>
<li>[actions] add workflow permissions</li>
<li>[Tests] <code>stringify</code>: increase coverage</li>
<li>[Dev Deps] update <code>eslint</code>,
<code>@ljharb/eslint-config</code>, <code>npmignore</code>,
<code>es-value-fixtures</code>, <code>for-each</code>,
<code>object-inspect</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="3fa11a5f64"><code>3fa11a5</code></a>
v6.14.1</li>
<li><a
href="a62670423c"><code>a626704</code></a>
[Dev Deps] update <code>npmignore</code></li>
<li><a
href="3086902ecf"><code>3086902</code></a>
[Fix] ensure arrayLength applies to <code>[]</code> notation as
well</li>
<li><a
href="fc7930e86c"><code>fc7930e</code></a>
[Dev Deps] update <code>eslint</code>,
<code>@ljharb/eslint-config</code></li>
<li><a
href="0b06aac566"><code>0b06aac</code></a>
[Dev Deps] update <code>@ljharb/eslint-config</code></li>
<li><a
href="64951f6200"><code>64951f6</code></a>
[Refactor] <code>parse</code>: extract key segment splitting helper</li>
<li><a
href="e1bd2599cd"><code>e1bd259</code></a>
[Dev Deps] update <code>@ljharb/eslint-config</code></li>
<li><a
href="f4b3d39709"><code>f4b3d39</code></a>
[eslint] add eslint 9 optional peer dep</li>
<li><a
href="6e94d9596c"><code>6e94d95</code></a>
[Dev Deps] update <code>eslint</code>,
<code>@ljharb/eslint-config</code>, <code>npmignore</code></li>
<li><a
href="973dc3c51c"><code>973dc3c</code></a>
[actions] add workflow permissions</li>
<li>Additional commits viewable in <a
href="https://github.com/ljharb/qs/compare/v6.14.0...v6.14.1">compare
view</a></li>
</ul>
</details>
<br />

Updates `body-parser` from 1.20.3 to 1.20.4
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/expressjs/body-parser/releases">body-parser's
releases</a>.</em></p>
<blockquote>
<h2>1.20.4</h2>
<h2>What's Changed</h2>
<ul>
<li>Remove redundant depth check by <a
href="https://github.com/blakeembrey"><code>@​blakeembrey</code></a> in
<a
href="https://redirect.github.com/expressjs/body-parser/pull/538">expressjs/body-parser#538</a></li>
<li>ci: add support for Node.js v23 by <a
href="https://github.com/Phillip9587"><code>@​Phillip9587</code></a> in
<a
href="https://redirect.github.com/expressjs/body-parser/pull/553">expressjs/body-parser#553</a></li>
<li>ci: restore CI for 1.x branch by <a
href="https://github.com/bjohansebas"><code>@​bjohansebas</code></a> in
<a
href="https://redirect.github.com/expressjs/body-parser/pull/665">expressjs/body-parser#665</a></li>
<li>deps: qs@^6.14.0 by <a
href="https://github.com/bjohansebas"><code>@​bjohansebas</code></a> in
<a
href="https://redirect.github.com/expressjs/body-parser/pull/664">expressjs/body-parser#664</a></li>
<li>deps: use tilde notation and update certain dependencies by <a
href="https://github.com/Phillip9587"><code>@​Phillip9587</code></a> in
<a
href="https://redirect.github.com/expressjs/body-parser/pull/668">expressjs/body-parser#668</a></li>
<li>chore: remove SECURITY.md by <a
href="https://github.com/Phillip9587"><code>@​Phillip9587</code></a> in
<a
href="https://redirect.github.com/expressjs/body-parser/pull/669">expressjs/body-parser#669</a></li>
<li>ci: add CodeQL (SAST) by <a
href="https://github.com/Phillip9587"><code>@​Phillip9587</code></a> in
<a
href="https://redirect.github.com/expressjs/body-parser/pull/670">expressjs/body-parser#670</a></li>
<li>Release: 1.20.4 by <a
href="https://github.com/UlisesGascon"><code>@​UlisesGascon</code></a>
in <a
href="https://redirect.github.com/expressjs/body-parser/pull/672">expressjs/body-parser#672</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/expressjs/body-parser/compare/1.20.3...1.20.4">https://github.com/expressjs/body-parser/compare/1.20.3...1.20.4</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/expressjs/body-parser/blob/master/HISTORY.md">body-parser's
changelog</a>.</em></p>
<blockquote>
<h1>1.20.4 / 2025-12-01</h1>
<ul>
<li>deps: qs@~6.14.0</li>
<li>deps: use tilde notation for dependencies</li>
<li>deps: http-errors@~2.0.1</li>
<li>deps: raw-body@~2.5.3</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="7db202cac8"><code>7db202c</code></a>
1.20.4 (<a
href="https://redirect.github.com/expressjs/body-parser/issues/672">#672</a>)</li>
<li><a
href="d8f8adb898"><code>d8f8adb</code></a>
ci: add CodeQL (SAST) (<a
href="https://redirect.github.com/expressjs/body-parser/issues/670">#670</a>)</li>
<li><a
href="6d133c19b3"><code>6d133c1</code></a>
chore: remove SECURITY.md (<a
href="https://redirect.github.com/expressjs/body-parser/issues/669">#669</a>)</li>
<li><a
href="fcd1535504"><code>fcd1535</code></a>
deps: use tilde notation and update certain dependencies (<a
href="https://redirect.github.com/expressjs/body-parser/issues/668">#668</a>)</li>
<li><a
href="ec5fa290d2"><code>ec5fa29</code></a>
deps: qs@~6.14.0 (<a
href="https://redirect.github.com/expressjs/body-parser/issues/664">#664</a>)</li>
<li><a
href="ffb95c12c7"><code>ffb95c1</code></a>
ci: restore CI for 1.x branch (<a
href="https://redirect.github.com/expressjs/body-parser/issues/665">#665</a>)</li>
<li><a
href="48a5f074a4"><code>48a5f07</code></a>
ci: add support for Node.js v23 (<a
href="https://redirect.github.com/expressjs/body-parser/issues/553">#553</a>)</li>
<li><a
href="f20f6adc71"><code>f20f6ad</code></a>
Remove redundant depth check (<a
href="https://redirect.github.com/expressjs/body-parser/issues/538">#538</a>)</li>
<li>See full diff in <a
href="https://github.com/expressjs/body-parser/compare/1.20.3...1.20.4">compare
view</a></li>
</ul>
</details>
<br />

Updates `express` from 4.21.2 to 4.22.1
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/expressjs/express/releases">express's
releases</a>.</em></p>
<blockquote>
<h2>v4.22.1</h2>
<h2>What's Changed</h2>
<blockquote>
<p>[!IMPORTANT]<br />
The prior release (4.22.0) included an erroneous breaking change related
to the extended query parser. There is no actual security vulnerability
associated with this behavior (CVE-2024-51999 has been rejected). The
change has been fully reverted in this release.</p>
</blockquote>
<ul>
<li>Release: 4.22.1 by <a
href="https://github.com/UlisesGascon"><code>@​UlisesGascon</code></a>
in <a
href="https://redirect.github.com/expressjs/express/pull/6934">expressjs/express#6934</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/expressjs/express/compare/4.22.0...v4.22.1">https://github.com/expressjs/express/compare/4.22.0...v4.22.1</a></p>
<h2>4.22.0</h2>
<h2>Important: Security</h2>
<ul>
<li>Security fix for <a
href="https://www.cve.org/CVERecord?id=CVE-2024-51999">CVE-2024-51999</a>
(<a
href="https://github.com/expressjs/express/security/advisories/GHSA-pj86-cfqh-vqx6">GHSA-pj86-cfqh-vqx6</a>)</li>
</ul>
<h2>What's Changed</h2>
<ul>
<li>Refactor: improve readability by <a
href="https://github.com/sazk07"><code>@​sazk07</code></a> in <a
href="https://redirect.github.com/expressjs/express/pull/6190">expressjs/express#6190</a></li>
<li>ci: add support for Node.js@23.0 by <a
href="https://github.com/UlisesGascon"><code>@​UlisesGascon</code></a>
in <a
href="https://redirect.github.com/expressjs/express/pull/6080">expressjs/express#6080</a></li>
<li>Method functions with no path should error by <a
href="https://github.com/wesleytodd"><code>@​wesleytodd</code></a> in <a
href="https://redirect.github.com/expressjs/express/pull/5957">expressjs/express#5957</a></li>
<li>ci: updated github actions ci workflow by <a
href="https://github.com/Phillip9587"><code>@​Phillip9587</code></a> in
<a
href="https://redirect.github.com/expressjs/express/pull/6323">expressjs/express#6323</a></li>
<li>ci: reorder <code>npm i</code> steps to fix ci for older node
versions by <a
href="https://github.com/Phillip9587"><code>@​Phillip9587</code></a> in
<a
href="https://redirect.github.com/expressjs/express/pull/6336">expressjs/express#6336</a></li>
<li>Backport: ci: add node.js 24 to test matrix by <a
href="https://github.com/Phillip9587"><code>@​Phillip9587</code></a> in
<a
href="https://redirect.github.com/expressjs/express/pull/6506">expressjs/express#6506</a></li>
<li>chore(4.x): wider range for query test skip by <a
href="https://github.com/jonchurch"><code>@​jonchurch</code></a> in <a
href="https://redirect.github.com/expressjs/express/pull/6513">expressjs/express#6513</a></li>
<li>use tilde notation for certain dependencies by <a
href="https://github.com/UlisesGascon"><code>@​UlisesGascon</code></a>
in <a
href="https://redirect.github.com/expressjs/express/pull/6905">expressjs/express#6905</a></li>
<li>deps: qs@6.14.0 by <a
href="https://github.com/UlisesGascon"><code>@​UlisesGascon</code></a>
in <a
href="https://redirect.github.com/expressjs/express/pull/6909">expressjs/express#6909</a></li>
<li>deps: use tilde notation for <code>qs</code> by <a
href="https://github.com/Phillip9587"><code>@​Phillip9587</code></a> in
<a
href="https://redirect.github.com/expressjs/express/pull/6919">expressjs/express#6919</a></li>
<li>Release: 4.22.0 by <a
href="https://github.com/UlisesGascon"><code>@​UlisesGascon</code></a>
in <a
href="https://redirect.github.com/expressjs/express/pull/6921">expressjs/express#6921</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/expressjs/express/compare/4.21.2...4.22.0">https://github.com/expressjs/express/compare/4.21.2...4.22.0</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/expressjs/express/blob/v4.22.1/History.md">express's
changelog</a>.</em></p>
<blockquote>
<h1>4.22.1 / 2025-12-01</h1>
<ul>
<li>Revert security fix for <a
href="https://www.cve.org/CVERecord?id=CVE-2024-51999">CVE-2024-51999</a>
(<a
href="https://github.com/expressjs/express/security/advisories/GHSA-pj86-cfqh-vqx6">GHSA-pj86-cfqh-vqx6</a>)</li>
</ul>
<h1>4.22.0 / 2025-12-01</h1>
<ul>
<li>Security fix for <a
href="https://www.cve.org/CVERecord?id=CVE-2024-51999">CVE-2024-51999</a>
(<a
href="https://github.com/expressjs/express/security/advisories/GHSA-pj86-cfqh-vqx6">GHSA-pj86-cfqh-vqx6</a>)</li>
<li>deps: use tilde notation for dependencies</li>
<li>deps: qs@6.14.0</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="12fae14531"><code>12fae14</code></a>
4.22.1</li>
<li><a
href="5ddf311af3"><code>5ddf311</code></a>
Revert &quot;sec: security patch for CVE-2024-51999&quot;</li>
<li><a
href="49744abd11"><code>49744ab</code></a>
4.22.0 (<a
href="https://redirect.github.com/expressjs/express/issues/6921">#6921</a>)</li>
<li><a
href="6e97452f60"><code>6e97452</code></a>
sec: security patch for CVE-2024-51999</li>
<li><a
href="6a23d34d65"><code>6a23d34</code></a>
deps: use tilde notation for <code>qs</code> (<a
href="https://redirect.github.com/expressjs/express/issues/6919">#6919</a>)</li>
<li><a
href="8c12cdf93b"><code>8c12cdf</code></a>
deps: qs@6.14.0 (<a
href="https://redirect.github.com/expressjs/express/issues/6909">#6909</a>)</li>
<li><a
href="7fea74fcf0"><code>7fea74f</code></a>
deps: use tilde notation for certain dependencies (<a
href="https://redirect.github.com/expressjs/express/issues/6905">#6905</a>)</li>
<li><a
href="dac7a0475a"><code>dac7a04</code></a>
chore: wider range for query test skip (<a
href="https://redirect.github.com/expressjs/express/issues/6513">#6513</a>)</li>
<li><a
href="997919b488"><code>997919b</code></a>
ci: add node.js 24 to test matrix (<a
href="https://redirect.github.com/expressjs/express/issues/6506">#6506</a>)</li>
<li><a
href="36fb59c6c7"><code>36fb59c</code></a>
fix(ci): reorder <code>npm i</code> steps to fix ci for older node
versions (<a
href="https://redirect.github.com/expressjs/express/issues/6336">#6336</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/expressjs/express/compare/4.21.2...v4.22.1">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/a2aproject/a2a-js/network/alerts).

</details>

Co-authored-by: Ivan Shymko <ishymko@google.com>
2026-01-07 11:12:15 +01:00
tchapacan
5246067f5f
feat: use case-insensitive transport protocol name comparison in ClientFactory (#281)
# Description

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make
sure it goes smoothly:

- [x] Follow the [`CONTRIBUTING`
Guide](https://github.com/google-a2a/a2a-js/blob/main/CONTRIBUTING.md).
- [x] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- Important Prefixes for
[release-please](https://github.com/googleapis/release-please):
- `fix:` which represents bug fixes, and correlates to a
[SemVer](https://semver.org/) patch.
- `feat:` represents a new feature, and correlates to a SemVer minor.
- `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking
change (indicated by the `!`) and will result in a SemVer major.
- [x] Ensure the tests and linter pass
- [ ] Appropriate docs were updated (if necessary)

Fixes #264 🦕

Release-As: 0.3.8

---------

Co-authored-by: Ivan Shimko <vana.shimko@gmail.com>
2025-12-23 08:22:02 +01:00
Ivan Shymko
89b141b5ba
fix: pass ServerCallContext to getAuthenticatedExtendedAgentCard for REST (#274)
# Description

Follow-up for #142: authenticated agent card logic relies on context to
determine authentication status.

`src/server/transports/rest/rest_transport_handler.ts` is not exported,
so adding a required parameter is fine.

Re #137
2025-12-17 14:53:43 +00:00
Ivan Shymko
23cd42e83d
fix: export transport agnostic errors from client (#272)
# Description

Due to a name conflict with legacy JSON-RPC types reexported from
`src/index.ts` below errors are going to be exported via
`src/client/index.ts` to allow usage from external transport
implementations.

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-12-17 15:34:30 +01:00
tchapacan
96be3a1d6c
feat: add rest client (#258)
# Description

Following continuation of this PR
https://github.com/a2aproject/a2a-js/pull/142, this one is related to
the implementation of the REST mode support for the client part of
**a2a-js** sdk. Following the same pattern as other sdk (agnostic
transport).

----

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make
sure it goes smoothly:

- [x] Follow the [`CONTRIBUTING`
Guide](https://github.com/google-a2a/a2a-js/blob/main/CONTRIBUTING.md).
- [x] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- Important Prefixes for
[release-please](https://github.com/googleapis/release-please):
- `fix:` which represents bug fixes, and correlates to a
[SemVer](https://semver.org/) patch.
- `feat:` represents a new feature, and correlates to a SemVer minor.
- `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking
change (indicated by the `!`) and will result in a SemVer major.
- [x] Ensure the tests and linter pass
- [ ] Appropriate docs were updated (if necessary)

Fixes #137, fixes #175 🦕

Release-As: 0.3.7

Co-authored-by: Ivan Shymko <ishymko@google.com>
2025-12-17 11:38:44 +01:00
Drew Foxall
6c76fef264
feat: remove EventEmitter dependency to support Edge Runtime (#219)
## Summary

This PR addresses [issue
#218](https://github.com/a2aproject/a2a-js/issues/218) by replacing the
Node.js-specific `EventEmitter` with the web-standard `EventTarget` API,
enabling the SDK to run natively on edge runtimes (Cloudflare Workers,
Deno, Bun) without requiring Node.js compatibility modes.

## Changes

### Replace EventEmitter with EventTarget

**File:** `src/server/events/execution_event_bus.ts`

- Removes Node.js `events` module dependency
- Uses web-standard `EventTarget` API available in all modern runtimes
- Maintains backward-compatible API (`on`, `off`, `once`,
`removeAllListeners`)
- Adds `ExecutionEventName` type alias for `'event' | 'finished'`
- Includes `CustomEvent` polyfill for Node.js 15-18 (built-in from
Node.js 19+)

## Implementation Details

### EventEmitter Behavior Compatibility

The implementation faithfully replicates EventEmitter semantics:

- **FIFO dispatch order** - Listeners fire in the order they were
registered
- **`this` context** - Listeners are invoked with `this` bound to the
event bus instance
- **Memory semantics** - Listeners are held via strong references until
explicitly removed (identical to EventEmitter)

### Type Safety

- Uses type guards (`isAgentExecutionCustomEvent`) for safe runtime
narrowing - no unsafe casts
- `'finished'` event listeners are invoked with no arguments (using
`Function.prototype.call`) matching EventEmitter behavior
- Internal listener tracking uses `readonly` Maps

## Benefits

- ✅ **Native Cloudflare Workers support** - No `nodejs_compat` flag
needed
- ✅ **Native Deno support** - No `npm:` shims required  
- ✅ **Native Bun support** - Full web API compatibility
- ✅ **Browser compatibility** - True universal JavaScript
- ✅ **Node.js 15+** - EventTarget is built-in

## Breaking Changes

- Requires **Node.js 15+** (EventTarget support)
- Node.js 14 no longer supported (EOL anyway)

## Testing

- All **146 existing tests pass** with these changes
- Added **27 new tests** for `DefaultExecutionEventBus` covering:
  - Basic `on`/`off`/`once` functionality
  - Multiple registrations of same listener
  - `once()` auto-cleanup behavior
  - `removeAllListeners()` for specific events and all events
  - Event firing order (FIFO)
  - Method chaining
  - `this` context binding

## Related Work

I've implemented and tested these changes in my fork:
- Fork: https://github.com/drew-foxall/a2a-js-sdk
- Working Hono implementation:
https://github.com/drew-foxall/a2a-js-sdk-examples

Closes #218

Release-As: 0.3.7
2025-12-15 08:28:25 +01:00
Ivan Shymko
8da480e54f
docs: update docs for 0.3.6 (#246)
# Description

1. Update README.md, sample agents and sample CLI to use new APIs
introduced in #162 (extract middlewares from `A2AExpressApp`) and #198
(transport-agnostic client).
2. Mark `A2AExpressApp` and `A2AClient` as deprecated.
3. Ensure samples and TCK import via index files only to "test" that all
required types are exported.
4.  Consolidate all `@example` tags to use ` ```ts `.
2025-12-10 15:53:59 +00:00
Ivan Shymko
6a3bc0b709
refactor: define and export helper API for Extensions (#251)
# Description

Define types and utility functions for extensions to export for external
usage and share between client and server.

Re #218 #219
2025-12-10 15:50:26 +00:00
Ivan Shymko
67a1217abd
refactor: properly specify export type (#248)
# Description

Fix exports for newly introduced client symbols.
2025-12-10 12:27:43 +01:00
Ivan Shymko
919cbaaa65
refactor: rename HTTP REST to REST (#247)
# Description

Follow-up for unreleased #142.

[The spec](https://a2a-protocol.org/latest/specification/) uses
[`HTTP+JSON/REST`](https://a2a-protocol.org/latest/specification/#11-httpjsonrest-protocol-binding)
wording and other SDKs use just REST in all names (i.e.
[Python](https://github.com/a2aproject/a2a-python/blob/main/src/a2a/server/request_handlers/rest_handler.py)
and
[Golang](https://github.com/a2aproject/a2a-go/blob/release/spec-v1/a2asrv/rest.go)).
2025-12-10 10:35:22 +00:00
Ivan Shymko
22551f9b28
refactor: improve ClientFactory.createFrom array merging logic (#245)
# Description

Update `ClientFactory.createFrom` merging logic to work better with
common use-cases:

1. Merge transports by `TransportFactory.protocolName` to allow the
following:
```ts
const factory = new ClientFactory(ClientFactoryOptions.createFrom(ClientFactoryOptions.default, {
  transports: [
    new JsonRpcTransportFactory({ fetchImpl: myCustomFetch })
  ]
}))
```
2. Concatenate interceptors to allow providing SDK default interceptors.
3. Other config-like arrays (`preferredTransports`,
`clientConfig.acceptedOutputModes`) are replaced.

Re: follow-up for unreleased #240
2025-12-10 10:28:05 +00:00
Guglielmo Colombo
cdbaf64240
refactor: reverse execution order of interceptors in the after interceptor (#244)
# Description

This PR reverses the execution order of interceptors in the
interceptAfter method. It ensures symmetry with interceptBefore, meaning
the last interceptor called during the 'before' phase is the first one
called during the 'after' phase.

---------

Co-authored-by: Ivan Shymko <vana.shimko@gmail.com>
2025-12-10 09:08:24 +00:00
dependabot[bot]
9706438a9e
chore(deps-dev): bump jws from 3.2.2 to 3.2.3 in /src/samples (#233)
Bumps [jws](https://github.com/brianloveswords/node-jws) from 3.2.2 to
3.2.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/brianloveswords/node-jws/releases">jws's
releases</a>.</em></p>
<blockquote>
<h2>v3.2.3</h2>
<h3>Changed</h3>
<ul>
<li>Fix advisory GHSA-869p-cjfg-cm3x: createSign and createVerify now
require
that a non empty secret is provided (via opts.secret, opts.privateKey or
opts.key)
when using HMAC algorithms.</li>
<li>Upgrading JWA version to 1.4.2, addressing a compatibility issue for
Node &gt;= 25.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/auth0/node-jws/blob/master/CHANGELOG.md">jws's
changelog</a>.</em></p>
<blockquote>
<h2>[3.2.3]</h2>
<h3>Changed</h3>
<ul>
<li>Fix advisory GHSA-869p-cjfg-cm3x: createSign and createVerify now
require
that a non empty secret is provided (via opts.secret, opts.privateKey or
opts.key)
when using HMAC algorithms.</li>
<li>Upgrading JWA version to 1.4.2, adressing a compatibility issue for
Node &gt;= 25.</li>
</ul>
<h2>[3.0.0]</h2>
<h3>Changed</h3>
<ul>
<li><strong>BREAKING</strong>: <code>jwt.verify</code> now requires an
<code>algorithm</code> parameter, and
<code>jws.createVerify</code> requires an <code>algorithm</code> option.
The <code>&quot;alg&quot;</code> field
signature headers is ignored. This mitigates a critical security flaw
in the library which would allow an attacker to generate signatures with
arbitrary contents that would be accepted by <code>jwt.verify</code>.
See
<a
href="https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/">https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/</a>
for details.</li>
</ul>
<h2><a
href="https://github.com/brianloveswords/node-jws/compare/v1.0.1...v2.0.0">2.0.0</a>
- 2015-01-30</h2>
<h3>Changed</h3>
<ul>
<li>
<p><strong>BREAKING</strong>: Default payload encoding changed from
<code>binary</code> to
<code>utf8</code>. <code>utf8</code> is a is a more sensible default
than <code>binary</code> because
many payloads, as far as I can tell, will contain user-facing
strings that could be in any language. (<!-- raw HTML omitted --><a
href="https://github.com/brianloveswords/node-jws/commit/6b6de48">6b6de48</a><!--
raw HTML omitted -->)</p>
</li>
<li>
<p>Code reorganization, thanks <a
href="https://github.com/fearphage"><code>@​fearphage</code></a>! (<!--
raw HTML omitted --><a
href="https://github.com/brianloveswords/node-jws/commit/7880050">7880050</a><!--
raw HTML omitted -->)</p>
</li>
</ul>
<h3>Added</h3>
<ul>
<li>Option in all relevant methods for <code>encoding</code>. For those
few users
that might be depending on a <code>binary</code> encoding of the
messages, this
is for them. (<!-- raw HTML omitted --><a
href="https://github.com/brianloveswords/node-jws/commit/6b6de48">6b6de48</a><!--
raw HTML omitted -->)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="4f6e73f24d"><code>4f6e73f</code></a>
Merge commit from fork</li>
<li><a
href="bd0fea57f3"><code>bd0fea5</code></a>
version 3.2.3</li>
<li><a
href="7c3b4b4110"><code>7c3b4b4</code></a>
Enhance tests for HMAC streaming sign and verify</li>
<li><a
href="a9b8ed999d"><code>a9b8ed9</code></a>
Improve secretOrKey initialization in VerifyStream</li>
<li><a
href="6707fde62c"><code>6707fde</code></a>
Improve secret handling in SignStream</li>
<li>See full diff in <a
href="https://github.com/brianloveswords/node-jws/compare/v3.2.2...v3.2.3">compare
view</a></li>
</ul>
</details>
<details>
<summary>Maintainer changes</summary>
<p>This version was pushed to npm by <a
href="https://www.npmjs.com/~julien.wollscheid">julien.wollscheid</a>, a
new releaser for jws since your current version.</p>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=jws&package-manager=npm_and_yarn&previous-version=3.2.2&new-version=3.2.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/a2aproject/a2a-js/network/alerts).

</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ivan Shimko <vana.shimko@gmail.com>
2025-12-10 08:00:04 +00:00
tchapacan
f20e66247d
feat: implement server http+json (#142)
# Description

## Add HTTP+REST ServerSide Transport Support

- Server: REST endpoints/routes addition by taking advantage of
pre-existing express from the codebase. Following this
[doc](https://a2a-protocol.org/latest/specification/#356-method-mapping-reference-table)
and internally rerouting to each a2a handler method containing the
buisness logic

Some part of the code has been generated using generative AI to speed up
the development, I have reviewed it carefully, but this should be taken
into account into the review. Keep in mind this is my first time
contributing to the repo and this is an attempt to help a2a-js support
REST (HTTP+JSON) as per describe in the [a2a
documentation](https://a2a-protocol.org/latest/specification/#323-httpjsonrest-transport).
I'll be happy to refacto it during review process, don't hesitate to
challenge it.

---

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make
sure it goes smoothly:

- [x] Follow the [`CONTRIBUTING`
Guide](https://github.com/google-a2a/a2a-js/blob/main/CONTRIBUTING.md).
- [x] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- Important Prefixes for
[release-please](https://github.com/googleapis/release-please):
- `fix:` which represents bug fixes, and correlates to a
[SemVer](https://semver.org/) patch.
- `feat:` represents a new feature, and correlates to a SemVer minor.
- `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking
change (indicated by the `!`) and will result in a SemVer major.
- [x] Ensure the tests and linter pass
- [ ] Appropriate docs were updated (if necessary)

Re #137 🦕

Release-As: 0.3.6
2025-12-10 08:33:22 +01:00
Ivan Shymko
4ad73c118a
refactor: rename ClientFactory.createFromAgentCardUrl -> createFromUrl (#242)
# Description

`createFromAgentCardUrl` may give a wrong impression that full URL has
to be provided, rename and add examples.

Not yet released, `AgentCardResolver` and the method were added in #225.

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-12-09 17:15:38 +01:00
Ivan Shymko
1ca8c8b225
refactor: define a helper function to customize ClientFactoryOptions (#240)
# Description

Deep cloning each object and array for adding an interceptor into
default client config (for example) is quite involved, define a helper
function so that it can be done as follows:

```ts
const options = ClientFactoryOptions.createFrom(ClientFactoryOptions.default, {
  clientConfig: { interceptors: [new MyInterceptor()] },
});
```
2025-12-09 12:27:38 +01:00
Guglielmo Colombo
47854792b6
feat: add AgentCard to interceptors parameters (#236)
# Description

This PR add a feature to PR #223 adding the agentCard to the
interceptors' parameters. Some values of the agentCard may be necessary
at the interceptors level (e.g. security schemes).

BEGIN_COMMIT_OVERRIDE
refactor: add AgentCard to interceptors parameters
END_COMMIT_OVERRIDE
2025-12-08 14:05:35 +00:00
Ivan Shymko
7d9a0c7515
refactor: pass ServerCallContext to TaskStore (#235)
# Description

Pass `ServerCallContext` to `TaskStore` to allow DB-backed stores.
Enhance comments for `User`, stating that `userName` is a unique
identifier.

Re #213
2025-12-08 10:24:47 +00:00
Guglielmo Colombo
3073376f7c
feat: add support for extendedAgentCard on client side (#234)
# Description

This PR adds the support on client side for the
getAuthenticatedExtendedCard api.

Fixes #196 🦕

Release-As: 0.3.6

---------

Co-authored-by: Ivan Shymko <vana.shimko@gmail.com>
2025-12-07 17:29:15 +00:00
Guglielmo Colombo
8c57002add
feat: Add support for extension headers on client side (#227)
# Description

This PR implements the support for extensions on client side

Fixes #170 🦕

Release-As: 0.3.6

---------

Co-authored-by: Ivan Shymko <ishymko@google.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-12-05 12:40:00 +00:00
Ivan Shymko
7250d328fa
refactor: define typed API for client call context (#232)
# Description

Provides typed API to read and update context to make predefined and
externally defined keys composable in the same way.

```ts
export type SystemParameters = Record<string, string>;

export const systemParametersKey = new ClientCallContextKey<SystemParameters>('systemParameters');

const myContext = ClientCallContext.create(
  systemParametersKey.set({ 'X-A2A-Extensions': 'http://example.com' })
);

const myParameters = systemParametersKey.get(myContext);
```

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-12-05 11:13:37 +00:00
Ivan Shymko
01287978af
refactor: rename const objects properties to camelCase (#231)
# Description

Those types were not released, so renaming to use JS/TS common style of
camelCase.
2025-12-04 17:22:26 +01:00
Guglielmo Colombo
8494544520
fix: change context parameter in RequestOptions from mandatory to optional (#228)
# Description

This PR changes the `context` parameter in `RequestOptions` from
mandatory to optional.

Fix for #223 which is not yet released, so overriding changelog entry
below to avoid extra message for unreleased functionality.

BEGIN_COMMIT_OVERRIDE
refactor: change `context` parameter in `RequestOptions` from mandatory
to optional
END_COMMIT_OVERRIDE
2025-12-03 16:11:50 +01:00
Ivan Shymko
83072f6d6e
fix: properly invoke CallInterceptor.after for async generators (#226)
1. `after` wasn't invoked in case of early return from `before` for
executed interceptors as done in non-generators methods.
2. `after` wasn't invoked for non-streaming fallback from
`sendMessageStream`.

Fix for #223 which is not yet released, so overriding changelog entry
below to avoid extra message for unreleased functionality.

BEGIN_COMMIT_OVERRIDE
refactor: properly invoke CallInterceptor.after for async generators
END_COMMIT_OVERRIDE
2025-12-03 13:57:07 +01:00
Ivan Shymko
ddaf7ded16
feat: introduce AgentCardResolver (#225)
# Description

Define `AgentCardResolver` and wire it up with `ClientFactory` via a new
method `createFromAgentCardUrl`.

Release-As: 0.3.6
2025-12-03 11:37:50 +01:00
Ivan Shymko
5694c22e3b
feat: implement client interceptors (#223)
# Description

Implement client interceptors and export multi-transport client types to
prepare for upcoming release.

Interceptors support "early return" both before and after transport
invocation. For early return before transport invocation client invokes
appropriate "after" methods of executed interceptors.

Release-As: 0.3.6

---------

Co-authored-by: Guglielmo Colombo <guglielmoc@google.com>
2025-12-03 11:25:41 +01:00
Ivan Shymko
2db7e3867f
ci: run npm run lint (#224)
# Description

`tsc --noEmit` added in #214 as a part of `npm run lint` wasn't executed
in CI.

Add it and fix errors introduced while it wasn't running.
2025-12-02 13:39:23 +01:00
Guglielmo Colombo
cc9d223e69
docs: create a sample for authentication feature (#211)
# Description

This PR introduces a sample for the authentication feature.

Re #195

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-12-01 16:09:53 +01:00
Guglielmo Colombo
a0cc13575c
refactor: create a dedicated package.json for samples (#216)
# Description

This PR creates a new `package.json` in the `samples` folder, not to
pollute the main `package.json` with libraries specific to the samples.
2025-11-28 15:48:52 +00:00
Ivan Shymko
c2a246828c
refactor: add RequestOptions to multitransport client (#215)
# Description

Propagate `RequestOptions` down to `Transport`.

Re #198, was missing in the original PR - wasn't release yet, so no
impact.
2025-11-28 12:55:34 +00:00
Guglielmo Colombo
31c1a6e822
build: run tsc --noEmit on lint (#214)
# Description

`tsup` does not perform strict type checking before the generation of
the `d.ts` files. Adding the `tsc --noEmit` step checks for types
violation.

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Ivan Shymko <vana.shimko@gmail.com>
2025-11-28 11:36:30 +00:00
Ivan Shymko
94a9848399
feat: introduce transport agnostic client (#198)
# Description

As a next step after #169, define a transport agnostic client.

# Changes

## Main
- Define `Client` built around core types, not JSON-RPC wrappers.
- Define `ClientFactory` to dynamically select transport among available
based on agent card and factory level preferences.

## Misc
- Rename `A2ATransport` to `Transport` (this type is not yet exported
via `index.ts`).
- Add `AbortSignal` to `Transport` and new client for cancellation.
- Add basic E2E test for `sendMessage` and `sendMessageStream` using
server SDK wired up with real expressjs app and invoked via newly
created client.
- Fix `getTaskPushNotificationConfig` types in transport.

# TODOs
- Client interceptors.
- Extensions support.

Re #137, #142

Release-As: 0.3.6
2025-11-27 16:16:30 +01:00
Ivan Shymko
5dfeee9664
refactor: make userBuilder non-nullable in A2AExpressApp (#205)
Re #202
2025-11-27 10:19:42 +00:00
Ivan Shymko
8938e73d2c
refactor: require user builder in JsonRpcHandlerOptions (#202)
# Description

Marking as refactor, since updated type wasn't released yet.

Making `userBuilder` a mandatory parameter for `JsonRpcHandlerOptions`
and define a helper `UserBuilder.NoAuthentication` to make it explicit.

Re #195.
2025-11-27 11:13:07 +01:00
Guglielmo Colombo
b72bda503a
fix: Populate the ServerCallContext user param when a new ServerCallContext is created (#200)
# Description

This PR is a fix for the bug caused by the user being deleted when the
request is containing requested extensions, as a new ServerCallContext
was created without copying the `context.user`.

Fixes #199 🦕
PRs #171, #195 

BEGIN_COMMIT_OVERRIDE
refactor: Populate the ServerCallContext user param when a new
ServerCallContext is created
END_COMMIT_OVERRIDE
2025-11-27 08:40:48 +00:00
Guglielmo Colombo
45014ac4a1
feat: Implement extended card support on server side (#197)
# Description

This PR introduces a more robust implementation of the
`getAuthenticatedExtendedAgentCard` API.
The user may inject in the `default_request_handler` an AgentCart object
or a callback (`ExtendedAgentCardProvider`) which receives as input
parameters the `ServerCallContext` and returns an AgentCard object.

- If extendedAgentCardProvider is provided as callback: The logic
delegates entirely to the callback. This allows consumers to implement
custom authorization check if the user has insufficient permissions.
- If extendedAgentCardProvider is provided as AgentCard object:
1. User in context is Authenticated: Returns extendedAgentCard.
2. User in context is Unauthenticated: Returns the basic agentCard.

Fixes #196  🦕

Release-As: 0.3.6

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-11-26 10:42:09 +01:00
Guglielmo Colombo
9872d93622
feat: support authentication on server side (#195)
# Description

This PR integrates a support for authentication on the server side.
A new `User` interface is created to represent the Authenticated and
UnAuthenticated user in the context, with 2 required function:
1. isAuthenticathed()
2. userName()

The callback `authenticathedUserExtractor` provided to the
`A2AExpressApp` is responsible for extracting the user object from the
Request (if set up by the authentication middleware), and returning an
instance of the `User` interface. The returned instance will be added to
the ServerCallContext.
If no authentication middleware or no `authenticathedUserExtractor` is
provided to the Server, the user in the ServerCallContext will be of
type UnAuthenticated.

Fixes #194  🦕

Release-As: 0.3.6
2025-11-25 11:39:29 +01:00
Guglielmo Colombo
9d7208250a
build: enable no-explicit-any in eslint (#190)
# Description

The purpose of this PR is removing all the references to keyword 'any'
present in the repository, as it is considered a bad practice. Future
adoptions will be triggered by the linter automatic checks


Fixes #184  🦕
2025-11-20 12:37:07 +01:00
Guglielmo Colombo
e55c0f4791
fix: handle errors occurred in non-blocking sendMessage (#187)
# Description

This PR fixes the error of server crash in case of error in the event
loop for non blocking event, if the first reply to the client has been
already sent.
Two different error handling strategies are implemented based on the
origin of the error:

1. If the error originates from the pushNotification service, the loop
is not interrupted, and the error is simply printed on the console error
output
2. If the error is originating from the ExecutionEventQueue or from a
taskStore operation (resultManager interaction), the error is
interrupting the loop.
In the catch clause a TaskStatusUpdateEvent is generated, with
taskStatus equal to "failed", if an already existing Task has been
processed by the ResultManager. The new TaskStatusUpdateEvent is saved
in the taskStore. If a new error occurs within this operation, it is
simply printed on the console error output.

Fixes #186  🦕
2025-11-19 10:46:54 +00:00
Ivan Shymko
dc9f7dc832
refactor: extract JSON-RPC specific logic from client (#169)
# Description

Currently `A2AClient` defined in `client.ts` uses JSON-RPC types in its
interface, i.e. `sendMessage` uses
[`SendMessageResponse`](e7e8f35d5d/src/client/client.ts (L207))
which contains [JSON-RPC fields like `id` and `jsonrpc`
version](e7e8f35d5d/src/types.ts (L2177-L2190)).
It was also the case for Python SDK which required introducing a new
[client.py](https://github.com/a2aproject/a2a-python/blob/main/src/a2a/client/client.py)
keeping the old one as
[legacy.py](https://github.com/a2aproject/a2a-python/blob/main/src/a2a/client/legacy.py)
for backward compatibility (see
[#348](https://github.com/a2aproject/a2a-python/pull/348)).

As a first step of introducing a transport-agnostic client, extract
JSON-RPC specific logic into a transport abstraction and switch existing
`A2AClient` to it in a backward compatible way to take advantage of
existing tests.

**Note:** new types are not exported from `index.ts`, this will be done
once new client is ready.

# Changes

1. Define `A2ATransport` abstraction without using JSON-RPC types.
2. Implement `JsonRpcTransport` from existing `A2AClient`.
3. Use new `JsonRpcTransport` from `A2AClient` - new transports are
**not going** to be added into this client as it uses JSON-RPC types.
This is done in a backward compatible way, existing behavior is
preserved: returning JSON-RPC errors as objects, populating JSON-RPC
specific fields.
4. Define shared transport-agnostic errors for A2A specific errors
defined in [the
spec](https://a2a-protocol.org/latest/specification/#82-a2a-specific-errors).

Re #137, #142
2025-11-19 10:00:27 +01:00
Guglielmo Colombo
542c5fba70
ci: integrate prettier check in github workflow (#185)
# Description

This PR integrates the prettier check in the github workflow to ensure
the code respects the correct formatting standards

Fixes #177  🦕

---------

Co-authored-by: Ivan Shymko <vana.shimko@gmail.com>
2025-11-18 17:06:18 +01:00
Guglielmo Colombo
e7e8f35d5d
ci: introduce workflow for linter (#183)
# Description

This pull request introduces a new ESLint configuration file,
`eslint.config.mjs` to standardize code quality and style across the
project.

Here's a summary of the key changes:

- ESLint Setup with TypeScript and Prettier Integration: The
configuration now leverages @eslint/js and typescript-eslint for linting
of TypeScript code. eslint-config-prettier is included to disable any
ESLint rules that might conflict with Prettier's formatting, which will
be included in a new PR.
- Ignored Files: The dist/ and node_modules/ directories are explicitly
ignored to prevent linting of generated output and third-party
dependencies.

Custom Rule Adjustments:

- @typescript-eslint/no-explicit-any is turned off to allow the use of
the any type where necessary.
- @typescript-eslint/no-unused-vars is configured to ignore unused
arguments and caught errors that are prefixed with an underscore (_).
This is a common pattern to signal intentional unused variables.

Test File Specific Rules: 
- @typescript-eslint/no-unused-expressions is turned off to accommodate
testing libraries like Chai, which often use expression-based
assertions.
- @typescript-eslint/no-unsafe-function-type is turned off to allow more
flexible function type usage within test contexts.

Node.js Global Variables: The configuration now includes globals.node to
correctly recognize Node.js global variables, preventing false positives
for undefined variables in Node.js environments.


The changes in other files in this PR are necessary for the linter
checks to pass. They involve mainly the removal of unused parameters.


Re #177  🦕
2025-11-17 16:30:29 +01:00
Guglielmo Colombo
5ef7396075
feat: server side support for extensions (#171)
# Description

The code submitted in the PR introduces the support for extensions on
the server side.

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make
sure it goes smoothly:

- [x] Follow the [`CONTRIBUTING`
Guide](https://github.com/google-a2a/a2a-js/blob/main/CONTRIBUTING.md).
- [x] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- Important Prefixes for
[release-please](https://github.com/googleapis/release-please):
- `fix:` which represents bug fixes, and correlates to a
[SemVer](https://semver.org/) patch.
- `feat:` represents a new feature, and correlates to a SemVer minor.
- `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking
change (indicated by the `!`) and will result in a SemVer major.
- [x] Ensure the tests and linter pass
- [x] Appropriate docs were updated (if necessary)

Fixes #170 🦕

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-11-17 10:13:21 +01:00
Ivan Shymko
3d23332c26
refactor: extract request handlers from A2AExpressApp (#162)
# Description

As a preparation step for REST support proposed in #142, extract
Express.js handlers from `A2AExpressApp` to allow assembling your own
app using Express.js API directly for specifying individual paths and
middlewares, rather than wrapping it in `A2AExpressApp`:

```ts
// const a2aRequestHandler = . . .

const app = express();

// Minimal example:
app.use(`/${AGENT_CARD_PATH}`, agentCardHandler({ agentCardProvider: a2aRequestHandler }));
app.use(jsonRpcHandler({ requestHandler: a2aRequestHandler }));

// Advanced example:
app.use(myCustomMiddleware());
app.use('/.well-known/custom-agent-card.json', myCustomAgentCardMiddleware, agentCardHandler({ agentCardProvider: a2aRequestHandler }));
app.use('/a2a/jsonrpc', myJsonRpcMiddleware, jsonRpcHandler({ requestHandler: a2aRequestHandler }));
app.use('/a2a/api', restHandler({ requestHandler: a2aRequestHandler }));
```

No logic changes to existing handlers, they are moved as is. Also
`A2AExpressApp` is switched to use new handlers without behavior
changes.

**Note:** new functions **are not** exported via `index.ts` yet, it will
be done together with updating docs and examples once REST support is
done.

Re #137
2025-11-12 18:54:41 -08:00
Ivan Shymko
67869e46b3
refactor: do not string match error message thrown in the same block (#167)
# Description

Minor fix in `client.ts` error handling: avoid checking an error thrown
within the same block via a string match. Include `cause` into rethrown
error.
2025-11-07 14:10:50 +01:00
Guglielmo Colombo
3eec0bd98a
fix: cancel/task now returns the expected 'cancelled' task status (#158)
# Description

The current implementation of the cancel/task did not return the task in
'cancelled' status, because it was not consuming all the events on the
eventBus, but was taking the last published one.
This PR fixes this tck
[test](9893cfdb5f/tests/mandatory/protocol/test_tasks_cancel_method.py (L39))

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make
sure it goes smoothly:

- [x] Follow the [`CONTRIBUTING`
Guide](https://github.com/google-a2a/a2a-js/blob/main/CONTRIBUTING.md).
- [x] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- Important Prefixes for
[release-please](https://github.com/googleapis/release-please):
- `fix:` which represents bug fixes, and correlates to a
[SemVer](https://semver.org/) patch.
- `feat:` represents a new feature, and correlates to a SemVer minor.
- `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking
change (indicated by the `!`) and will result in a SemVer major.
- [x] Ensure the tests and linter pass
- [x] Appropriate docs were updated (if necessary)

Fixes #157 🦕
2025-11-03 08:59:55 +01:00