agentconnect-cli 0.1.0a4__tar.gz → 0.1.0a6__tar.gz
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.
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/PKG-INFO +14 -14
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/README.md +9 -9
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/pyproject.toml +7 -7
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/pyproject.toml.orig +7 -7
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/__init__.py +1 -1
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/a2a_adapter/adapter.py +134 -20
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/a2a_adapter/cards.py +3 -1
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/a2a_adapter/facade.py +33 -4
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/adapter.py +38 -2
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/adapters.py +34 -2
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/apiclient.py +51 -7
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/callback.py +61 -14
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/cli.py +1278 -36
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/cli_json.py +125 -2
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/cli_support.py +38 -3
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/clock.py +8 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/config.py +321 -50
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/deliveries.py +25 -2
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/directory_client.py +23 -5
- agentconnect_cli-0.1.0a6/src/agentconnect/entry.py +55 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/failpoints.py +8 -3
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/isolation.py +113 -8
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/keystore.py +39 -4
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/limits.py +100 -27
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/mcp/backend.py +15 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/mcp/server.py +10 -8
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/mcp/session.py +19 -1
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/mcp/tools.py +35 -3
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/payloads.py +17 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/policy.py +20 -1
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/relay.py +25 -2
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/agent.py +32 -8
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/api.py +696 -51
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/engine.py +2207 -277
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/errors.py +1 -0
- agentconnect_cli-0.1.0a6/src/agentconnect/runtime/evaluation.py +198 -0
- agentconnect_cli-0.1.0a6/src/agentconnect/runtime/forkwatch.py +133 -0
- agentconnect_cli-0.1.0a6/src/agentconnect/runtime/freshness.py +585 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/groups.py +268 -13
- agentconnect_cli-0.1.0a6/src/agentconnect/runtime/introductions.py +477 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/knocks.py +587 -41
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/listing.py +17 -0
- agentconnect_cli-0.1.0a6/src/agentconnect/runtime/owner_domains.py +259 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/runtime.py +2 -0
- agentconnect_cli-0.1.0a6/src/agentconnect/runtime/succession.py +439 -0
- agentconnect_cli-0.1.0a6/src/agentconnect/runtime/tier.py +85 -0
- agentconnect_cli-0.1.0a6/src/agentconnect/runtime/trust.py +1665 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/schemas.py +22 -4
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/sse.py +38 -2
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/store.py +1385 -75
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/tokens.py +2 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/webhook.py +11 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/a2a_adapter/__init__.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/a2a_adapter/convert.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/a2a_adapter/seen.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/a2a_adapter/serve.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/api_tls.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/backoff.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/daemon/__init__.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/identity.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/log.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/mcp/__init__.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/ownerfile.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/provision.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/py.typed +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/__init__.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/floor.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/ledger.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/registry.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/runtime/sas.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/sas_emoji.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/shapes.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/sockets.py +0 -0
- {agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/tasks.py +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentconnect-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0a6
|
|
4
4
|
Summary: AgentConnect daemon (agentconnectd) and CLI
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
|
-
Requires-Dist: a2a-sdk[http-server,signing]>=1.
|
|
7
|
-
Requires-Dist: agentconnect-core==0.1.
|
|
6
|
+
Requires-Dist: a2a-sdk[http-server,signing]>=1.3.1
|
|
7
|
+
Requires-Dist: agentconnect-core==0.1.0a6
|
|
8
8
|
Requires-Dist: cryptography>=50.0.2
|
|
9
|
-
Requires-Dist: httpx>=0.
|
|
9
|
+
Requires-Dist: httpx>=0.29.0
|
|
10
10
|
Requires-Dist: keyring>=25.7.0
|
|
11
11
|
Requires-Dist: mcp>=2.3.0
|
|
12
12
|
Requires-Dist: pyjwt[crypto]>=2.15.1
|
|
13
13
|
Requires-Dist: structlog>=26.1.0
|
|
14
|
-
Requires-Dist: typer>=0.
|
|
14
|
+
Requires-Dist: typer>=0.28.0
|
|
15
15
|
Requires-Dist: uvicorn>=0.54.0
|
|
16
16
|
Requires-Dist: websockets>=17.3
|
|
17
17
|
Requires-Python: >=3.12
|
|
@@ -21,8 +21,8 @@ Description-Content-Type: text/markdown
|
|
|
21
21
|
|
|
22
22
|
The AgentConnect daemon (`agentconnectd`) and CLI (`agentconnect`). The
|
|
23
23
|
distribution is `agentconnect-cli`; the command and the import package are
|
|
24
|
-
`agentconnect`. See the repository [README](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
25
|
-
[SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
24
|
+
`agentconnect`. See the repository [README](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/README.md) and
|
|
25
|
+
[SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/SPEC.md).
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
28
|
agentconnect daemon run [--config PATH] [--tcp-port N] # foreground, JSON logs on stderr
|
|
@@ -32,12 +32,12 @@ agentconnect status [--json] # reads the local API
|
|
|
32
32
|
Everything protocol-related is in the runtime, `agentconnect.runtime`
|
|
33
33
|
(`Runtime`, with its engine, local API, adapters and agent-scope
|
|
34
34
|
`AgentApi`). `agentconnectd` (`agentconnect.daemon`) is one host of it; the
|
|
35
|
-
Python SDK's embedded mode (`AgentConnect.embedded`, [docs/sdk.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
35
|
+
Python SDK's embedded mode (`AgentConnect.embedded`, [docs/sdk.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/sdk.md))
|
|
36
36
|
is the other. Both run the same checks, and both serve the local API below.
|
|
37
37
|
|
|
38
38
|
The invite lifecycle (`group`, `invite`, `accept`, `groups`, `approvals`,
|
|
39
39
|
`verify`, `leave`, `send`, `events`) is documented in
|
|
40
|
-
[docs/cli.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
40
|
+
[docs/cli.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/cli.md), with the `--json` schemas and exit codes.
|
|
41
41
|
`approvals approve`, `approvals reject` and `verify` use the human token:
|
|
42
42
|
**never give an agent the human token or let it run those commands for the
|
|
43
43
|
human.**
|
|
@@ -46,7 +46,7 @@ Don't give agents shell or file access to the data directory either: an
|
|
|
46
46
|
agent that can read it can approve joins and mark codes verified as you,
|
|
47
47
|
because the human token is a file there. Agents that need a shell can run
|
|
48
48
|
as another OS user, with the daemon under a user of its own
|
|
49
|
-
([docs/isolation.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
49
|
+
([docs/isolation.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/isolation.md)).
|
|
50
50
|
|
|
51
51
|
## What the daemon holds
|
|
52
52
|
|
|
@@ -64,14 +64,14 @@ as another OS user, with the daemon under a user of its own
|
|
|
64
64
|
|
|
65
65
|
The data directory (`~/.local/share/agentconnect`) is 0700 and every file in
|
|
66
66
|
it 0600. Configuration is `~/.config/agentconnect/config.toml`; see
|
|
67
|
-
[docs/config.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
67
|
+
[docs/config.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/config.md) for the keys and the `AC_*` overrides.
|
|
68
68
|
|
|
69
69
|
## Local control API
|
|
70
70
|
|
|
71
71
|
JSON over HTTP/1.1 on a Unix socket in the data directory, or on
|
|
72
72
|
`https://127.0.0.1:<port>` (TLS with a certificate the clients pin). Every
|
|
73
73
|
request needs `Authorization: Bearer <token>`.
|
|
74
|
-
[docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
74
|
+
[docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/api.md) describes the transport, tokens, errors and
|
|
75
75
|
every route with its request and response shapes.
|
|
76
76
|
|
|
77
77
|
Two tokens live in the data directory: `api-token` (agent scope) and
|
|
@@ -99,7 +99,7 @@ repeat a message or an event. Every delivery has a stable `msg_id` and every
|
|
|
99
99
|
event a stable `event_id`; deduplicate by them. Nothing is lost: an event is
|
|
100
100
|
recorded before the adapter hears of it and sent again on restart until
|
|
101
101
|
`on_event` returns (ADR-004).
|
|
102
|
-
The webhook adapter ([docs/adapters/webhook.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
102
|
+
The webhook adapter ([docs/adapters/webhook.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/adapters/webhook.md)) and the SSE adapter (`GET /v0/events`, [docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/api.md#event-stream)) serve headless agents.
|
|
103
103
|
`CallbackAdapter` (`agentconnect.callback`) is the embedded SDK's in-process adapter, with the webhook's retry rules. `RecordingAdapter` is the in-memory adapter used by tests. Every message in
|
|
104
104
|
and out goes through the safety policy (`agentconnect.policy`) before any
|
|
105
|
-
adapter sees it ([docs/safety.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
105
|
+
adapter sees it ([docs/safety.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/safety.md)).
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The AgentConnect daemon (`agentconnectd`) and CLI (`agentconnect`). The
|
|
4
4
|
distribution is `agentconnect-cli`; the command and the import package are
|
|
5
|
-
`agentconnect`. See the repository [README](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
6
|
-
[SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
5
|
+
`agentconnect`. See the repository [README](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/README.md) and
|
|
6
|
+
[SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/SPEC.md).
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
9
|
agentconnect daemon run [--config PATH] [--tcp-port N] # foreground, JSON logs on stderr
|
|
@@ -13,12 +13,12 @@ agentconnect status [--json] # reads the local API
|
|
|
13
13
|
Everything protocol-related is in the runtime, `agentconnect.runtime`
|
|
14
14
|
(`Runtime`, with its engine, local API, adapters and agent-scope
|
|
15
15
|
`AgentApi`). `agentconnectd` (`agentconnect.daemon`) is one host of it; the
|
|
16
|
-
Python SDK's embedded mode (`AgentConnect.embedded`, [docs/sdk.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
16
|
+
Python SDK's embedded mode (`AgentConnect.embedded`, [docs/sdk.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/sdk.md))
|
|
17
17
|
is the other. Both run the same checks, and both serve the local API below.
|
|
18
18
|
|
|
19
19
|
The invite lifecycle (`group`, `invite`, `accept`, `groups`, `approvals`,
|
|
20
20
|
`verify`, `leave`, `send`, `events`) is documented in
|
|
21
|
-
[docs/cli.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
21
|
+
[docs/cli.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/cli.md), with the `--json` schemas and exit codes.
|
|
22
22
|
`approvals approve`, `approvals reject` and `verify` use the human token:
|
|
23
23
|
**never give an agent the human token or let it run those commands for the
|
|
24
24
|
human.**
|
|
@@ -27,7 +27,7 @@ Don't give agents shell or file access to the data directory either: an
|
|
|
27
27
|
agent that can read it can approve joins and mark codes verified as you,
|
|
28
28
|
because the human token is a file there. Agents that need a shell can run
|
|
29
29
|
as another OS user, with the daemon under a user of its own
|
|
30
|
-
([docs/isolation.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
30
|
+
([docs/isolation.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/isolation.md)).
|
|
31
31
|
|
|
32
32
|
## What the daemon holds
|
|
33
33
|
|
|
@@ -45,14 +45,14 @@ as another OS user, with the daemon under a user of its own
|
|
|
45
45
|
|
|
46
46
|
The data directory (`~/.local/share/agentconnect`) is 0700 and every file in
|
|
47
47
|
it 0600. Configuration is `~/.config/agentconnect/config.toml`; see
|
|
48
|
-
[docs/config.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
48
|
+
[docs/config.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/config.md) for the keys and the `AC_*` overrides.
|
|
49
49
|
|
|
50
50
|
## Local control API
|
|
51
51
|
|
|
52
52
|
JSON over HTTP/1.1 on a Unix socket in the data directory, or on
|
|
53
53
|
`https://127.0.0.1:<port>` (TLS with a certificate the clients pin). Every
|
|
54
54
|
request needs `Authorization: Bearer <token>`.
|
|
55
|
-
[docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
55
|
+
[docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/api.md) describes the transport, tokens, errors and
|
|
56
56
|
every route with its request and response shapes.
|
|
57
57
|
|
|
58
58
|
Two tokens live in the data directory: `api-token` (agent scope) and
|
|
@@ -80,7 +80,7 @@ repeat a message or an event. Every delivery has a stable `msg_id` and every
|
|
|
80
80
|
event a stable `event_id`; deduplicate by them. Nothing is lost: an event is
|
|
81
81
|
recorded before the adapter hears of it and sent again on restart until
|
|
82
82
|
`on_event` returns (ADR-004).
|
|
83
|
-
The webhook adapter ([docs/adapters/webhook.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
83
|
+
The webhook adapter ([docs/adapters/webhook.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/adapters/webhook.md)) and the SSE adapter (`GET /v0/events`, [docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/api.md#event-stream)) serve headless agents.
|
|
84
84
|
`CallbackAdapter` (`agentconnect.callback`) is the embedded SDK's in-process adapter, with the webhook's retry rules. `RecordingAdapter` is the in-memory adapter used by tests. Every message in
|
|
85
85
|
and out goes through the safety policy (`agentconnect.policy`) before any
|
|
86
|
-
adapter sees it ([docs/safety.md](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
86
|
+
adapter sees it ([docs/safety.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a6/docs/safety.md)).
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "agentconnect-cli"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.0a6"
|
|
4
4
|
description = "AgentConnect daemon (agentconnectd) and CLI"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
7
7
|
requires-python = ">=3.12"
|
|
8
8
|
dependencies = [
|
|
9
|
-
"a2a-sdk[http-server,signing]>=1.
|
|
10
|
-
"agentconnect-core==0.1.
|
|
9
|
+
"a2a-sdk[http-server,signing]>=1.3.1",
|
|
10
|
+
"agentconnect-core==0.1.0a6",
|
|
11
11
|
"cryptography>=50.0.2",
|
|
12
|
-
"httpx>=0.
|
|
12
|
+
"httpx>=0.29.0",
|
|
13
13
|
"keyring>=25.7.0",
|
|
14
14
|
"mcp>=2.3.0",
|
|
15
15
|
"pyjwt[crypto]>=2.15.1",
|
|
16
16
|
"structlog>=26.1.0",
|
|
17
|
-
"typer>=0.
|
|
17
|
+
"typer>=0.28.0",
|
|
18
18
|
"uvicorn>=0.54.0",
|
|
19
19
|
"websockets>=17.3",
|
|
20
20
|
]
|
|
21
21
|
|
|
22
22
|
[project.scripts]
|
|
23
|
-
agentconnect = "agentconnect.
|
|
23
|
+
agentconnect = "agentconnect.entry:main"
|
|
24
24
|
|
|
25
25
|
[tool.uv.sources.agentconnect-core]
|
|
26
26
|
workspace = true
|
|
@@ -29,5 +29,5 @@ workspace = true
|
|
|
29
29
|
module-name = "agentconnect"
|
|
30
30
|
|
|
31
31
|
[build-system]
|
|
32
|
-
requires = ["uv_build>=0.13.
|
|
32
|
+
requires = ["uv_build>=0.13.10,<0.14"]
|
|
33
33
|
build-backend = "uv_build"
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "agentconnect-cli"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.0a6"
|
|
4
4
|
description = "AgentConnect daemon (agentconnectd) and CLI"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
7
7
|
requires-python = ">=3.12"
|
|
8
8
|
dependencies = [
|
|
9
|
-
"a2a-sdk[http-server,signing]>=1.
|
|
10
|
-
"agentconnect-core==0.1.
|
|
9
|
+
"a2a-sdk[http-server,signing]>=1.3.1",
|
|
10
|
+
"agentconnect-core==0.1.0a6",
|
|
11
11
|
"cryptography>=50.0.2",
|
|
12
|
-
"httpx>=0.
|
|
12
|
+
"httpx>=0.29.0",
|
|
13
13
|
"keyring>=25.7.0",
|
|
14
14
|
"mcp>=2.3.0",
|
|
15
15
|
"pyjwt[crypto]>=2.15.1",
|
|
16
16
|
"structlog>=26.1.0",
|
|
17
|
-
"typer>=0.
|
|
17
|
+
"typer>=0.28.0",
|
|
18
18
|
"uvicorn>=0.54.0",
|
|
19
19
|
"websockets>=17.3",
|
|
20
20
|
]
|
|
21
21
|
|
|
22
22
|
[project.scripts]
|
|
23
|
-
agentconnect = "agentconnect.
|
|
23
|
+
agentconnect = "agentconnect.entry:main"
|
|
24
24
|
|
|
25
25
|
[tool.uv.sources]
|
|
26
26
|
agentconnect-core = { workspace = true }
|
|
@@ -30,5 +30,5 @@ agentconnect-core = { workspace = true }
|
|
|
30
30
|
module-name = "agentconnect"
|
|
31
31
|
|
|
32
32
|
[build-system]
|
|
33
|
-
requires = ["uv_build>=0.13.
|
|
33
|
+
requires = ["uv_build>=0.13.10,<0.14"]
|
|
34
34
|
build-backend = "uv_build"
|
{agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/a2a_adapter/adapter.py
RENAMED
|
@@ -40,7 +40,7 @@ import json
|
|
|
40
40
|
import logging
|
|
41
41
|
import secrets
|
|
42
42
|
from collections import OrderedDict, deque
|
|
43
|
-
from collections.abc import AsyncIterator, Coroutine, Mapping
|
|
43
|
+
from collections.abc import AsyncIterator, Callable, Collection, Coroutine, Mapping
|
|
44
44
|
from dataclasses import dataclass, field
|
|
45
45
|
from pathlib import Path
|
|
46
46
|
from typing import TYPE_CHECKING, Any
|
|
@@ -74,7 +74,7 @@ from agentconnect.adapter import (
|
|
|
74
74
|
Sender,
|
|
75
75
|
)
|
|
76
76
|
from agentconnect.clock import Clock, unix_seconds
|
|
77
|
-
from agentconnect.isolation import facade_uids, receiver_uids, resolve_gid
|
|
77
|
+
from agentconnect.isolation import facade_uids, receiver_uids, resolve_gid, restricted_receiver_uids
|
|
78
78
|
from agentconnect.sockets import PeerMismatchError, receiver_async_transport
|
|
79
79
|
from agentconnect.tasks import cancel_and_wait
|
|
80
80
|
|
|
@@ -93,6 +93,30 @@ TASKS_PER_PEER = 64 # tasks kept per requesting instance in the database
|
|
|
93
93
|
CARD_TIMEOUT = 5.0
|
|
94
94
|
|
|
95
95
|
|
|
96
|
+
def _connection_dropped(e: BaseException) -> bool:
|
|
97
|
+
"""Whether a call failed because its connection went away under it
|
|
98
|
+
(read, write or protocol error), not because the agent couldn't be
|
|
99
|
+
reached or answered with an error."""
|
|
100
|
+
return isinstance(e.__cause__, (httpx.ReadError, httpx.WriteError, httpx.RemoteProtocolError))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _failure(e: BaseException) -> dict[str, Any]:
|
|
104
|
+
"""What a failed call to the local agent says about itself, for the
|
|
105
|
+
log: the error's class, the class of the network or HTTP error under it,
|
|
106
|
+
and the HTTP status if there was one. Never a URL or a body."""
|
|
107
|
+
cause = e.__cause__
|
|
108
|
+
return {
|
|
109
|
+
"error": type(e).__name__,
|
|
110
|
+
"cause": None if cause is None else type(cause).__name__,
|
|
111
|
+
"status": cause.response.status_code if isinstance(cause, httpx.HTTPStatusError) else None,
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
#: The restricted agent's base URL: its socket carries plain HTTP, so this
|
|
116
|
+
#: gives only the Host header and the paths.
|
|
117
|
+
RESTRICTED_URL = "http://localhost"
|
|
118
|
+
|
|
119
|
+
|
|
96
120
|
@dataclass(frozen=True)
|
|
97
121
|
class A2AOptions:
|
|
98
122
|
"""The adapter's configuration (``[a2a]`` in config.toml)."""
|
|
@@ -137,6 +161,21 @@ class A2AOptions:
|
|
|
137
161
|
data_dir=config.data_dir,
|
|
138
162
|
)
|
|
139
163
|
|
|
164
|
+
@staticmethod
|
|
165
|
+
def restricted_from_config(config: Config) -> A2AOptions:
|
|
166
|
+
"""The restricted tier's agent: on its socket, served by a restricted
|
|
167
|
+
user, with no facade, token or other setting of the main agent's.
|
|
168
|
+
The socket carries plain HTTP; the URL gives only Host and paths."""
|
|
169
|
+
return A2AOptions(
|
|
170
|
+
local_agent_url=RESTRICTED_URL,
|
|
171
|
+
local_agent_socket=config.a2a_restricted_socket,
|
|
172
|
+
receiver_uids=restricted_receiver_uids(config),
|
|
173
|
+
card_keys=cards.load_jwks(config.a2a_card_keys_file),
|
|
174
|
+
context_messages=config.a2a_context_messages,
|
|
175
|
+
frame_text=config.a2a_frame_text,
|
|
176
|
+
reply_timeout=float(config.a2a_reply_timeout),
|
|
177
|
+
)
|
|
178
|
+
|
|
140
179
|
|
|
141
180
|
@dataclass(frozen=True)
|
|
142
181
|
class TaskRef:
|
|
@@ -165,8 +204,12 @@ def message_id(d: Delivery) -> str:
|
|
|
165
204
|
class A2AAdapter:
|
|
166
205
|
"""See the module docstring."""
|
|
167
206
|
|
|
168
|
-
|
|
207
|
+
# The restricted tier's agent (ADR-007 Decision 6): its groups only.
|
|
208
|
+
restricted = False
|
|
209
|
+
|
|
210
|
+
def __init__(self, options: A2AOptions, name: str = "a2a", *, restricted: bool = False) -> None:
|
|
169
211
|
self.name = name
|
|
212
|
+
self.restricted = restricted
|
|
170
213
|
self.options = options
|
|
171
214
|
self._seen_store: Seen | None = None
|
|
172
215
|
self._send: OutboundSend | None = None
|
|
@@ -178,7 +221,8 @@ class A2AAdapter:
|
|
|
178
221
|
self._groups: dict[str, GroupView] = {}
|
|
179
222
|
self._cards: dict[str, dict[str, tuple[AgentCard, str]]] = {}
|
|
180
223
|
self._peers: dict[str, set[str]] = {}
|
|
181
|
-
|
|
224
|
+
# Per group: (the sending instance, the entry the agent gets).
|
|
225
|
+
self._context: dict[str, deque[tuple[str, dict[str, Any]]]] = {}
|
|
182
226
|
self._tasks: OrderedDict[str, TaskRef] = OrderedDict()
|
|
183
227
|
# The daemon's encrypted store, where the task map outlives a restart,
|
|
184
228
|
# and the runtime's clock for its entries.
|
|
@@ -187,6 +231,7 @@ class A2AAdapter:
|
|
|
187
231
|
self._running: set[asyncio.Task[None]] = set()
|
|
188
232
|
self.facade: Facade | None = None
|
|
189
233
|
self.facade_token: str | None = None
|
|
234
|
+
self._deliverable: Callable[[Delivery], bool] | None = None
|
|
190
235
|
|
|
191
236
|
def bind_store(self, store: Store) -> None:
|
|
192
237
|
"""The daemon's database: the local agent's tasks are kept there,
|
|
@@ -204,10 +249,12 @@ class A2AAdapter:
|
|
|
204
249
|
|
|
205
250
|
def _task(self, task_id: str) -> TaskRef | None:
|
|
206
251
|
"""One of the local agent's tasks, in memory or, after a restart,
|
|
207
|
-
in the daemon's database."""
|
|
252
|
+
in the daemon's database. None for an id with a NUL (``_task_key``)."""
|
|
253
|
+
if "\0" in task_id:
|
|
254
|
+
return None
|
|
208
255
|
ref = self._tasks.get(task_id)
|
|
209
256
|
if ref is None and self._store is not None:
|
|
210
|
-
row = self._store.a2a_task(task_id)
|
|
257
|
+
row = self._store.a2a_task(self._task_key(task_id))
|
|
211
258
|
ref = None if row is None else TaskRef(*row)
|
|
212
259
|
return ref
|
|
213
260
|
|
|
@@ -219,14 +266,24 @@ class A2AAdapter:
|
|
|
219
266
|
d.group_id, request, d.sender.identity, d.sender.instance_id
|
|
220
267
|
)
|
|
221
268
|
|
|
269
|
+
def _task_key(self, task_id: str) -> str:
|
|
270
|
+
"""The task map's key: the restricted agent's apart, so a task id it
|
|
271
|
+
picks can't replace or find the main agent's task of that id. The
|
|
272
|
+
prefix is in-band, so a task id with a NUL is never kept or found:
|
|
273
|
+
otherwise the main agent could name the restricted agent's key."""
|
|
274
|
+
return f"restricted\0{task_id}" if self.restricted else task_id
|
|
275
|
+
|
|
222
276
|
def _keep_task(self, task_id: str, ref: TaskRef) -> None:
|
|
277
|
+
if "\0" in task_id:
|
|
278
|
+
LOG.warning("a2a_task_id_refused", group=log.hid(ref.group_id))
|
|
279
|
+
return
|
|
223
280
|
self._tasks[task_id] = ref
|
|
224
281
|
self._tasks.move_to_end(task_id)
|
|
225
282
|
while len(self._tasks) > MAX_TASKS:
|
|
226
283
|
self._tasks.popitem(last=False)
|
|
227
284
|
if self._store is not None and self._clock is not None:
|
|
228
285
|
self._store.a2a_task_put(
|
|
229
|
-
task_id,
|
|
286
|
+
self._task_key(task_id),
|
|
230
287
|
group_id=ref.group_id,
|
|
231
288
|
requester=ref.requester,
|
|
232
289
|
instance=ref.instance,
|
|
@@ -384,18 +441,24 @@ class A2AAdapter:
|
|
|
384
441
|
entry = self._cards.get(group_id, {}).get(identity)
|
|
385
442
|
return None if entry is None else entry[1]
|
|
386
443
|
|
|
387
|
-
async def send_to_group(
|
|
444
|
+
async def send_to_group( # noqa: PLR0913 - keyword-only options
|
|
388
445
|
self,
|
|
389
446
|
group_id: str,
|
|
390
447
|
body: dict[str, Any],
|
|
391
448
|
to: list[str],
|
|
449
|
+
*,
|
|
392
450
|
kind: str = "a2a.message",
|
|
393
451
|
instance: str | None = None,
|
|
452
|
+
addressee: list[str] | None = None,
|
|
394
453
|
) -> str:
|
|
395
454
|
if self._send is None:
|
|
396
455
|
msg = "the adapter has not been started"
|
|
397
456
|
raise RuntimeError(msg)
|
|
398
|
-
|
|
457
|
+
if addressee is None:
|
|
458
|
+
return await self._send(group_id, body, to=to, kind=kind, instance=instance)
|
|
459
|
+
return await self._send(
|
|
460
|
+
group_id, body, to=to, kind=kind, instance=instance, addressee=addressee
|
|
461
|
+
)
|
|
399
462
|
|
|
400
463
|
# -- inbound -------------------------------------------------------------
|
|
401
464
|
|
|
@@ -437,7 +500,33 @@ class A2AAdapter:
|
|
|
437
500
|
if len(json.dumps(entry)) > MAX_CONTEXT_ENTRY:
|
|
438
501
|
entry = {k: v for k, v in entry.items() if k != "parts"} | {"omitted": "too_large"}
|
|
439
502
|
limit = max(self.options.context_messages, 0)
|
|
440
|
-
self._context.setdefault(d.group_id, deque(maxlen=limit))
|
|
503
|
+
context = self._context.setdefault(d.group_id, deque(maxlen=limit))
|
|
504
|
+
context.append((d.sender.instance_id, entry))
|
|
505
|
+
|
|
506
|
+
def withdraw(
|
|
507
|
+
self, group_id: str, identity: str, instances: Collection[str] | None = None
|
|
508
|
+
) -> list[dict[str, Any]]:
|
|
509
|
+
"""Forget ``identity``'s messages (only its ``instances``', when
|
|
510
|
+
given) kept as context for the next message to the local agent in
|
|
511
|
+
``group_id`` (:class:`~agentconnect.adapter.Withdraws`)."""
|
|
512
|
+
context = self._context.get(group_id)
|
|
513
|
+
if context is None:
|
|
514
|
+
return []
|
|
515
|
+
|
|
516
|
+
def theirs(item: tuple[str, dict[str, Any]]) -> bool:
|
|
517
|
+
instance, entry = item
|
|
518
|
+
return bool(entry["sender"] == identity) and (
|
|
519
|
+
instances is None or instance in instances
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
gone = [item[1] for item in context if theirs(item)]
|
|
523
|
+
kept = [item for item in context if not theirs(item)]
|
|
524
|
+
context.clear()
|
|
525
|
+
context.extend(kept)
|
|
526
|
+
return [
|
|
527
|
+
{"msg_id": str(e["msg_id"]), "kind": "a2a.message", "size": len(json.dumps(e))}
|
|
528
|
+
for e in gone
|
|
529
|
+
]
|
|
441
530
|
|
|
442
531
|
def _local_message(self, d: Delivery) -> Message:
|
|
443
532
|
peer = convert.parse_message(d.body)
|
|
@@ -461,6 +550,8 @@ class A2AAdapter:
|
|
|
461
550
|
"instance_id": d.sender.instance_id,
|
|
462
551
|
"display_name": d.sender.display_name,
|
|
463
552
|
"verified": d.sender.verified,
|
|
553
|
+
"trust": d.sender.trust,
|
|
554
|
+
"anchor": d.sender.anchor,
|
|
464
555
|
},
|
|
465
556
|
"to": list(d.to),
|
|
466
557
|
"addressed_to_me": d.addressed_to_me,
|
|
@@ -472,7 +563,7 @@ class A2AAdapter:
|
|
|
472
563
|
}
|
|
473
564
|
context = self._context.get(d.group_id)
|
|
474
565
|
if context is not None and len(context) > 0:
|
|
475
|
-
meta["context_messages"] =
|
|
566
|
+
meta["context_messages"] = [entry for _, entry in context]
|
|
476
567
|
peer_meta = convert.to_json(peer).get("metadata")
|
|
477
568
|
if peer_meta:
|
|
478
569
|
meta["peer_metadata"] = peer_meta
|
|
@@ -484,25 +575,35 @@ class A2AAdapter:
|
|
|
484
575
|
async def _ensure_client(self) -> bool:
|
|
485
576
|
return self._client is not None or await self._load_card()
|
|
486
577
|
|
|
578
|
+
def bind_deliverable(self, check: Callable[[Delivery], bool]) -> None:
|
|
579
|
+
"""Called by the runtime at start: whether a delivery may still go to
|
|
580
|
+
the local agent. The first call waits for the agent's card; a
|
|
581
|
+
delivery dropped meanwhile (its sender's connection ended) is
|
|
582
|
+
checked again before it is sent."""
|
|
583
|
+
self._deliverable = check
|
|
584
|
+
|
|
487
585
|
async def _trigger(self, group: GroupView, d: Delivery) -> DeliveryResult:
|
|
488
586
|
if not await self._ensure_client() or self._client is None or self._plain is None:
|
|
489
587
|
return DeliveryResult.RETRY # the local agent is unreachable for now
|
|
588
|
+
if self._deliverable is not None and not self._deliverable(d):
|
|
589
|
+
return DeliveryResult.ACK # dropped meanwhile: the local agent never sees it
|
|
490
590
|
request = SendMessageRequest(message=self._local_message(d))
|
|
491
591
|
try:
|
|
492
592
|
try:
|
|
493
|
-
stream =
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
593
|
+
first, stream = await self._send_local(self._client, self._plain, request)
|
|
594
|
+
except A2AClientError as e:
|
|
595
|
+
if not _connection_dropped(e):
|
|
596
|
+
raise
|
|
597
|
+
# The connection failed under the request: the agent closed
|
|
598
|
+
# a pooled keep-alive connection as the request went out on
|
|
599
|
+
# it (uvicorn closes one idle for 5 s). Send it once more,
|
|
600
|
+
# on a new connection, as a RETRY would later.
|
|
601
|
+
first, stream = await self._send_local(self._client, self._plain, request)
|
|
499
602
|
except A2AClientError as e:
|
|
500
603
|
refused = _refusal(e)
|
|
501
604
|
if refused is not None:
|
|
502
605
|
LOG.warning("a2a_receiver_refused", reason=str(refused))
|
|
503
|
-
LOG.warning(
|
|
504
|
-
"a2a_local_unreachable", group=log.hid(group.group_id), error=type(e).__name__
|
|
505
|
-
)
|
|
606
|
+
LOG.warning("a2a_local_unreachable", group=log.hid(group.group_id), **_failure(e))
|
|
506
607
|
return DeliveryResult.RETRY
|
|
507
608
|
except A2AError as e:
|
|
508
609
|
# A protocol error is the agent's answer, not a transient failure:
|
|
@@ -515,6 +616,19 @@ class A2AAdapter:
|
|
|
515
616
|
self._spawn(self._forward(d, first, stream))
|
|
516
617
|
return DeliveryResult.ACK
|
|
517
618
|
|
|
619
|
+
@staticmethod
|
|
620
|
+
async def _send_local(
|
|
621
|
+
client: Client, plain: Client, request: SendMessageRequest
|
|
622
|
+
) -> tuple[StreamResponse | None, AsyncIterator[StreamResponse]]:
|
|
623
|
+
"""Send to the local agent; its first response and the rest."""
|
|
624
|
+
try:
|
|
625
|
+
stream = aiter(client.send_message(request))
|
|
626
|
+
return await anext(stream, None), stream
|
|
627
|
+
except UnsupportedOperationError:
|
|
628
|
+
# The agent refused streaming: fall back to SendMessage.
|
|
629
|
+
stream = aiter(plain.send_message(request))
|
|
630
|
+
return await anext(stream, None), stream
|
|
631
|
+
|
|
518
632
|
def _spawn(self, work: Coroutine[Any, Any, None]) -> None:
|
|
519
633
|
task = asyncio.get_running_loop().create_task(work)
|
|
520
634
|
self._running.add(task)
|
|
@@ -33,6 +33,8 @@ from jwt import PyJWK
|
|
|
33
33
|
from jwt.exceptions import PyJWKError, PyJWTError
|
|
34
34
|
from jwt.utils import base64url_decode
|
|
35
35
|
|
|
36
|
+
from agentconnect.limits import MAX_PAYLOAD_DEPTH, loads
|
|
37
|
+
|
|
36
38
|
# Asymmetric only: a symmetric (HS*) key in a JWKS would let anyone holding
|
|
37
39
|
# it forge cards, and accepting HS* invites algorithm confusion.
|
|
38
40
|
ALGORITHMS = ["ES256", "ES384", "ES512", "RS256", "RS384", "RS512", "PS256", "PS384", "EdDSA"]
|
|
@@ -61,7 +63,7 @@ def _kids(card: AgentCard) -> list[str | None]:
|
|
|
61
63
|
kids: list[str | None] = []
|
|
62
64
|
for sig in card.signatures:
|
|
63
65
|
try:
|
|
64
|
-
header =
|
|
66
|
+
header = loads(base64url_decode(sig.protected.encode("ascii")), MAX_PAYLOAD_DEPTH)
|
|
65
67
|
except (ValueError, UnicodeError):
|
|
66
68
|
kids.append(None)
|
|
67
69
|
continue
|
{agentconnect_cli-0.1.0a4 → agentconnect_cli-0.1.0a6}/src/agentconnect/a2a_adapter/facade.py
RENAMED
|
@@ -149,6 +149,15 @@ class BridgeExecutor(AgentExecutor):
|
|
|
149
149
|
to = _to_list(meta.get("to")) if isinstance(meta, dict) else None
|
|
150
150
|
return to or ["*"]
|
|
151
151
|
|
|
152
|
+
def _one(self, to: list[str], follow_up: bool) -> str | None:
|
|
153
|
+
"""The one member a request names, on its path or as the only
|
|
154
|
+
identity in metadata.to: it alone is triggered (SPEC 9.3), and only
|
|
155
|
+
its replies answer the request. A follow-up goes to its task's
|
|
156
|
+
responder as before."""
|
|
157
|
+
if self._member is not None or follow_up:
|
|
158
|
+
return self._member
|
|
159
|
+
return to[0] if len(to) == 1 and to[0] != "*" else None
|
|
160
|
+
|
|
152
161
|
@override
|
|
153
162
|
async def execute(self, context: RequestContext, event_queue: EventQueue) -> None: # noqa: PLR0912
|
|
154
163
|
msg = context.message
|
|
@@ -164,10 +173,12 @@ class BridgeExecutor(AgentExecutor):
|
|
|
164
173
|
to = [bound.responder] if bound is not None else self._recipients(msg)
|
|
165
174
|
# A follow-up goes to the instance running the task (SPEC 9.4).
|
|
166
175
|
instance = None if bound is None else bound.instance
|
|
176
|
+
one = self._one(to, bound is not None)
|
|
177
|
+
addressee = [one] if one is not None and bound is None else None
|
|
167
178
|
replies: asyncio.Queue[Delivery] = asyncio.Queue()
|
|
168
179
|
try:
|
|
169
180
|
msg_id = await self._facade.adapter.send_to_group(
|
|
170
|
-
self._group_id, body, to, instance=instance
|
|
181
|
+
self._group_id, body, to, instance=instance, addressee=addressee
|
|
171
182
|
)
|
|
172
183
|
except Exception as e:
|
|
173
184
|
code = getattr(e, "code", type(e).__name__)
|
|
@@ -176,7 +187,7 @@ class BridgeExecutor(AgentExecutor):
|
|
|
176
187
|
event_queue, context, TaskState.TASK_STATE_FAILED, f"not sent: {code}"
|
|
177
188
|
)
|
|
178
189
|
return
|
|
179
|
-
self._facade.
|
|
190
|
+
self._facade.wait(msg_id, replies, one)
|
|
180
191
|
task_mode = context.current_task is not None
|
|
181
192
|
try:
|
|
182
193
|
if isinstance(msg_id, SendReceipt) and msg_id.held:
|
|
@@ -212,7 +223,7 @@ class BridgeExecutor(AgentExecutor):
|
|
|
212
223
|
await self._start_task(context, event_queue)
|
|
213
224
|
await self._status(event_queue, context, TaskState.TASK_STATE_FAILED, "no reply")
|
|
214
225
|
finally:
|
|
215
|
-
self._facade.
|
|
226
|
+
self._facade.unwait(msg_id)
|
|
216
227
|
|
|
217
228
|
async def _wait_for_human(
|
|
218
229
|
self, context: RequestContext, queue: EventQueue, receipt: SendReceipt
|
|
@@ -431,6 +442,8 @@ class Facade:
|
|
|
431
442
|
self._http = httpx.AsyncClient(timeout=10.0, trust_env=False, follow_redirects=False)
|
|
432
443
|
# msg_id sent by the facade -> the request waiting for replies to it
|
|
433
444
|
self.waiters: dict[str, asyncio.Queue[Delivery]] = {}
|
|
445
|
+
# msg_id of a request on a member's path -> the member it asked
|
|
446
|
+
self.members: dict[str, str] = {}
|
|
434
447
|
# facade task id -> its peer side
|
|
435
448
|
self.bound: dict[str, Bound] = {}
|
|
436
449
|
# hold id of a held facade send -> the human's decision, once it comes
|
|
@@ -512,16 +525,32 @@ class Facade:
|
|
|
512
525
|
if not future.done():
|
|
513
526
|
future.set_result(outcome)
|
|
514
527
|
|
|
528
|
+
def wait(self, msg_id: str, replies: asyncio.Queue[Delivery], member: str | None) -> None:
|
|
529
|
+
"""Route replies to the request ``msg_id`` to ``replies``; only
|
|
530
|
+
``member``'s, for a request that names one member."""
|
|
531
|
+
self.waiters[msg_id] = replies
|
|
532
|
+
if member is not None:
|
|
533
|
+
self.members[msg_id] = member
|
|
534
|
+
|
|
535
|
+
def unwait(self, msg_id: str) -> None:
|
|
536
|
+
self.waiters.pop(msg_id, None)
|
|
537
|
+
self.members.pop(msg_id, None)
|
|
538
|
+
|
|
515
539
|
def route_reply(self, d: Delivery) -> bool:
|
|
516
540
|
"""Hand a reply to the facade request it answers; False if none. Only
|
|
517
541
|
a member the request asked (SPEC 9.3) answers it: every member reads
|
|
518
542
|
the request, and an answer from anyone else is context, so it can't
|
|
519
|
-
stand in for the member the client asked, nor bind its task.
|
|
543
|
+
stand in for the member the client asked, nor bind its task. A
|
|
544
|
+
request on a member's path takes only that member's replies, in every
|
|
545
|
+
floor mode (SR-37); another member's goes on as any other message."""
|
|
520
546
|
refs = d.inner.get("reply_to")
|
|
521
547
|
if not isinstance(refs, list):
|
|
522
548
|
return False
|
|
523
549
|
for ref in refs:
|
|
524
550
|
queue = self.waiters.get(ref) if isinstance(ref, str) else None
|
|
551
|
+
member = self.members.get(ref) if isinstance(ref, str) else None
|
|
552
|
+
if member is not None and d.sender.identity != member:
|
|
553
|
+
continue
|
|
525
554
|
if queue is not None and self.adapter.asked(d, ref):
|
|
526
555
|
queue.put_nowait(d)
|
|
527
556
|
return True
|