@mono-agent/a2a-adapter 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -89
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
# @mono-agent/a2a-adapter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Expose a mono-agent as an A2A provider, or call a remote A2A provider from
|
|
4
|
+
programmatic host code.
|
|
4
5
|
|
|
5
6
|
## Category
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
<!-- package-metadata:start -->
|
|
9
|
+
<!-- Generated by scripts/generate-package-docs.mjs. Do not edit by hand. -->
|
|
10
|
+
|
|
11
|
+
Category: `communication`
|
|
12
|
+
Tier: `plugin`
|
|
13
|
+
Catalog responsibility: Exposes agent responders over A2A and consumes remote A2A agents through direct discovery.
|
|
14
|
+
|
|
15
|
+
<!-- package-metadata:end -->
|
|
8
16
|
|
|
9
17
|
## Responsibility
|
|
10
18
|
|
|
11
|
-
Expose
|
|
19
|
+
Expose an agent responder through an A2A Agent Card plus JSON-RPC/REST message
|
|
20
|
+
routes, and provide direct-discovery consumer clients for text/task calls.
|
|
12
21
|
|
|
13
22
|
This is a **plugin-tier** package: it publishes to npm in the mono-agent lockstep at the same version as the core packages, but it is not part of the core `@mono-agent/agent-app` dependency closure. `@mono-agent/agent-app` loads its provider channel only when a host declares it under `channels.plugins[]`.
|
|
14
23
|
|
|
@@ -16,11 +25,58 @@ This is a **plugin-tier** package: it publishes to npm in the mono-agent lockste
|
|
|
16
25
|
|
|
17
26
|
## Install / Usage
|
|
18
27
|
|
|
28
|
+
The A2A package is outside the core `@mono-agent/agent-app` closure. Install the
|
|
29
|
+
same lockstep version as the rest of the framework, then declare the provider
|
|
30
|
+
plugin in `mono-agent.config.json`:
|
|
31
|
+
|
|
19
32
|
```bash
|
|
20
|
-
pnpm
|
|
33
|
+
pnpm add @mono-agent/agent-app@latest @mono-agent/a2a-adapter@latest
|
|
21
34
|
```
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
The lockstep `latest` tags resolve to the same framework version. If the host
|
|
37
|
+
pins an older release, replace both `latest` tags with that same version.
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"agent": { "name": "Agent A" },
|
|
42
|
+
"channels": {
|
|
43
|
+
"plugins": [
|
|
44
|
+
{
|
|
45
|
+
"package": "@mono-agent/a2a-adapter",
|
|
46
|
+
"id": "a2a",
|
|
47
|
+
"config": {
|
|
48
|
+
"enabled": true,
|
|
49
|
+
"provider": { "host": "127.0.0.1", "port": 4300 },
|
|
50
|
+
"agent": {
|
|
51
|
+
"description": "Local A2A provider.",
|
|
52
|
+
"version": "0.1.0"
|
|
53
|
+
},
|
|
54
|
+
"skill": {
|
|
55
|
+
"id": "main",
|
|
56
|
+
"name": "Main",
|
|
57
|
+
"description": "Answers text prompts.",
|
|
58
|
+
"tags": ["mono-agent", "a2a"]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
mono-agent validate
|
|
69
|
+
mono-agent start --foreground
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The provider starts on loopback by default. It serves the Agent Card at
|
|
73
|
+
`/.well-known/agent-card.json` and message/task endpoints at `/a2a/json-rpc`
|
|
74
|
+
and `/a2a/rest`. Set `MONO_AGENT_A2A_BEARER_TOKEN` in `.env` when
|
|
75
|
+
`config.provider.requireBearer` is enabled. Non-loopback binding or a public
|
|
76
|
+
base URL also requires `allowNonLoopback: true`; terminate HTTPS in front of
|
|
77
|
+
the plaintext server.
|
|
78
|
+
|
|
79
|
+
Custom hosts can start a provider directly:
|
|
24
80
|
|
|
25
81
|
```ts
|
|
26
82
|
import { startA2AProvider } from "@mono-agent/a2a-adapter";
|
|
@@ -119,8 +175,54 @@ migration; startup refuses to reinterpret an existing manifest.
|
|
|
119
175
|
Config-loaded providers reject any partial `provider.idempotency` block that
|
|
120
176
|
omits the namespace; they never silently start without the advertised guard.
|
|
121
177
|
|
|
178
|
+
Provider config makes this agent callable. It does not automatically give the
|
|
179
|
+
agent a tool for calling peers. The consumer API remains programmatic: compose
|
|
180
|
+
`createA2AConsumerResponder`, `sendA2AMessage`, or `dispatchA2AMessage` in host
|
|
181
|
+
code. Plugin `config.consumer` supplies defaults to code that chooses to use
|
|
182
|
+
them; it does not create autonomous delegation by itself.
|
|
183
|
+
|
|
184
|
+
## Architecture
|
|
185
|
+
|
|
186
|
+
### Data flow
|
|
187
|
+
|
|
188
|
+
1. The channel driver layers plugin config and environment overrides, validates
|
|
189
|
+
the public Agent Card identity and network guard, then starts the provider
|
|
190
|
+
with the host's structural responder.
|
|
191
|
+
2. Provider routes authenticate before parsing the bounded body, translate A2A
|
|
192
|
+
text/task input into an `A2AAgentRequest`, and stream the responder's result
|
|
193
|
+
back through the SDK transport.
|
|
194
|
+
3. When enabled, the durable idempotency store binds a caller-supplied key to a
|
|
195
|
+
canonical execution fingerprint, replays the same task, and fails closed on
|
|
196
|
+
conflict, capacity, expired results, or in-doubt admissions.
|
|
197
|
+
4. Separately, consumer helpers discover a remote Agent Card, validate the
|
|
198
|
+
advertised capability, and send/observe/cancel requests. Observer timeout or
|
|
199
|
+
cancellation does not cancel the remote task; `dispatch.cancel()` is explicit.
|
|
200
|
+
|
|
201
|
+
### Package structure
|
|
202
|
+
|
|
203
|
+
| Source module | Responsibility |
|
|
204
|
+
| --- | --- |
|
|
205
|
+
| [`channel-driver.ts`](https://github.com/robertsreberski/mono-agent/blob/main/extras/a2a-adapter/src/channel-driver.ts) | Plugin-tier config-first provider lifecycle. |
|
|
206
|
+
| [`config.ts`](https://github.com/robertsreberski/mono-agent/blob/main/extras/a2a-adapter/src/config.ts) | Provider, card, skill, consumer, bearer, and idempotency config validation/redaction. |
|
|
207
|
+
| [`card.ts`](https://github.com/robertsreberski/mono-agent/blob/main/extras/a2a-adapter/src/card.ts) | Agent Card construction and extension advertisement. |
|
|
208
|
+
| [`provider.ts`](https://github.com/robertsreberski/mono-agent/blob/main/extras/a2a-adapter/src/provider.ts) | HTTP/SDK provider routes and responder translation. |
|
|
209
|
+
| [`consumer.ts`](https://github.com/robertsreberski/mono-agent/blob/main/extras/a2a-adapter/src/consumer.ts) | Discovery, send, dispatch, observation, cancellation, and responder facade. |
|
|
210
|
+
| [`idempotency.ts`](https://github.com/robertsreberski/mono-agent/blob/main/extras/a2a-adapter/src/idempotency.ts) | Durable admission records, result replay, permanent tombstones, and capacity checks. |
|
|
211
|
+
|
|
122
212
|
## Public API
|
|
123
213
|
|
|
214
|
+
### Start here
|
|
215
|
+
|
|
216
|
+
| API | Use it for |
|
|
217
|
+
| --- | --- |
|
|
218
|
+
| `createChannelDriver` / `createA2AChannelDriver` | Load the provider as a config-first `channels.plugins[]` entry. |
|
|
219
|
+
| `startA2AProvider` | Expose a responder from a custom host. |
|
|
220
|
+
| `createA2AAgentCard` | Build the exact card advertised by a custom provider. |
|
|
221
|
+
| `sendA2AMessage` | Send and await one direct remote text/task request. |
|
|
222
|
+
| `dispatchA2AMessage` | Admit long work, then observe or cancel the durable remote task separately. |
|
|
223
|
+
| `createA2AConsumer` / `createA2AConsumerResponder` | Reuse discovery and A2A calls inside a programmatic composition. |
|
|
224
|
+
| `loadA2AAdapterConfig` | Validate plugin/env settings without starting a server. |
|
|
225
|
+
|
|
124
226
|
<!-- public-api-inventory:start -->
|
|
125
227
|
<!-- Generated by scripts/generate-public-api-docs.mjs. Do not edit by hand. -->
|
|
126
228
|
|
|
@@ -188,90 +290,6 @@ startA2AProvider
|
|
|
188
290
|
|
|
189
291
|
<!-- public-api-inventory:end -->
|
|
190
292
|
|
|
191
|
-
Config can be loaded from a `channels.plugins[]` entry or explicit environment variables:
|
|
192
|
-
|
|
193
|
-
Set `MONO_AGENT_A2A_BEARER_TOKEN` in `.env` when `requireBearer` is enabled;
|
|
194
|
-
the source-config example omits the credential.
|
|
195
|
-
|
|
196
|
-
```json
|
|
197
|
-
{
|
|
198
|
-
"agent": {
|
|
199
|
-
"name": "Agent A"
|
|
200
|
-
},
|
|
201
|
-
"channels": {
|
|
202
|
-
"plugins": [
|
|
203
|
-
{
|
|
204
|
-
"package": "@mono-agent/a2a-adapter",
|
|
205
|
-
"id": "a2a",
|
|
206
|
-
"config": {
|
|
207
|
-
"enabled": true,
|
|
208
|
-
"provider": {
|
|
209
|
-
"host": "127.0.0.1",
|
|
210
|
-
"port": 4300,
|
|
211
|
-
"requireBearer": true,
|
|
212
|
-
"maxRequestBytes": 50000000,
|
|
213
|
-
"idempotency": {
|
|
214
|
-
"namespace": "agent-a-production",
|
|
215
|
-
"stateDir": ".mono-agent/a2a-agent-a",
|
|
216
|
-
"retentionMs": 2592000000,
|
|
217
|
-
"maxRecords": 10000
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
"agent": {
|
|
221
|
-
"description": "Local A2A provider.",
|
|
222
|
-
"version": "0.1.0"
|
|
223
|
-
},
|
|
224
|
-
"skill": {
|
|
225
|
-
"id": "agent-a",
|
|
226
|
-
"name": "Agent A",
|
|
227
|
-
"description": "Answers text prompts.",
|
|
228
|
-
"tags": ["mono-agent", "a2a"]
|
|
229
|
-
},
|
|
230
|
-
"consumer": {
|
|
231
|
-
"remoteAgentUrls": ["http://127.0.0.1:4300/.well-known/agent-card.json"],
|
|
232
|
-
"timeoutMs": 30000
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
]
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
Root `agent.name` is the default Agent Card name when the plugin's
|
|
242
|
-
`config.agent.name` is omitted. An A2A-specific `config.agent.name` or
|
|
243
|
-
`MONO_AGENT_A2A_AGENT_NAME` overrides that public default without changing the
|
|
244
|
-
root agent identity; `MONO_AGENT_NAME` is the environment override for the root
|
|
245
|
-
name.
|
|
246
|
-
|
|
247
|
-
Important env names:
|
|
248
|
-
|
|
249
|
-
- `MONO_AGENT_A2A_ENABLED`
|
|
250
|
-
- `MONO_AGENT_A2A_PROVIDER_ENABLED`
|
|
251
|
-
- `MONO_AGENT_A2A_HOST`
|
|
252
|
-
- `MONO_AGENT_A2A_PORT`
|
|
253
|
-
- `MONO_AGENT_A2A_PUBLIC_BASE_URL`
|
|
254
|
-
- `MONO_AGENT_A2A_ALLOW_NON_LOOPBACK`
|
|
255
|
-
- `MONO_AGENT_A2A_REQUIRE_BEARER`
|
|
256
|
-
- `MONO_AGENT_A2A_BEARER_TOKEN`
|
|
257
|
-
- `MONO_AGENT_A2A_MAX_REQUEST_BYTES`
|
|
258
|
-
- `MONO_AGENT_A2A_IDEMPOTENCY_NAMESPACE`
|
|
259
|
-
- `MONO_AGENT_A2A_IDEMPOTENCY_STATE_DIR`
|
|
260
|
-
- `MONO_AGENT_A2A_IDEMPOTENCY_RETENTION_MS`
|
|
261
|
-
- `MONO_AGENT_A2A_IDEMPOTENCY_MAX_RECORDS`
|
|
262
|
-
- `MONO_AGENT_NAME`
|
|
263
|
-
- `MONO_AGENT_A2A_AGENT_NAME`
|
|
264
|
-
- `MONO_AGENT_A2A_AGENT_DESCRIPTION`
|
|
265
|
-
- `MONO_AGENT_A2A_AGENT_VERSION`
|
|
266
|
-
- `MONO_AGENT_A2A_SKILL_ID`
|
|
267
|
-
- `MONO_AGENT_A2A_SKILL_NAME`
|
|
268
|
-
- `MONO_AGENT_A2A_SKILL_DESCRIPTION`
|
|
269
|
-
- `MONO_AGENT_A2A_SKILL_TAGS`
|
|
270
|
-
- `MONO_AGENT_A2A_REMOTE_AGENT_URLS`
|
|
271
|
-
- `MONO_AGENT_A2A_DEFAULT_REMOTE_AGENT_URL`
|
|
272
|
-
- `MONO_AGENT_A2A_CONSUMER_BEARER_TOKEN`
|
|
273
|
-
- `MONO_AGENT_A2A_TIMEOUT_MS`
|
|
274
|
-
|
|
275
293
|
## Dependency Boundary
|
|
276
294
|
|
|
277
295
|
This package depends only on `@mono-agent/agent-contracts` plus the pinned A2A SDK and Express transport surface. It does not depend on the agent harness, config package, operator surfaces, or other communication adapters.
|
|
@@ -280,6 +298,13 @@ This package depends only on `@mono-agent/agent-contracts` plus the pinned A2A S
|
|
|
280
298
|
|
|
281
299
|
It does not own runtime execution, memory, tool policy, central registries, signed cards, push notifications, file exchange, gRPC hosting, or autonomous LLM-selected remote-agent delegation. This pass supports direct discovery and text/task communication only.
|
|
282
300
|
|
|
301
|
+
## Related Documentation
|
|
302
|
+
|
|
303
|
+
- [A2A provider channel](https://mono-agent-docs.vercel.app/channels/a2a/)
|
|
304
|
+
- [Programmatic A2A consumer](https://mono-agent-docs.vercel.app/programmatic/a2a-consumer/)
|
|
305
|
+
- [A2A provider and consumer playbook](https://mono-agent-docs.vercel.app/playbooks/a2a-provider-and-consumer/)
|
|
306
|
+
- [Multi-agent composition](https://mono-agent-docs.vercel.app/programmatic/multi-agent/)
|
|
307
|
+
|
|
283
308
|
## Verification
|
|
284
309
|
|
|
285
310
|
Run:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mono-agent/a2a-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "A2A provider and consumer adapter for host-compatible runtimes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "GPL-3.0-only",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@a2a-js/sdk": "1.0.0-alpha.0",
|
|
30
|
-
"@mono-agent/agent-contracts": "0.
|
|
30
|
+
"@mono-agent/agent-contracts": "0.14.0",
|
|
31
31
|
"express": "^5.1.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|