agentconnect-cli 0.1.0a1__tar.gz → 0.1.0a3__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.0a1 → agentconnect_cli-0.1.0a3}/PKG-INFO +16 -14
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/README.md +11 -10
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/pyproject.toml +6 -5
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/pyproject.toml.orig +6 -5
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/__init__.py +1 -1
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/a2a_adapter/adapter.py +127 -10
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/a2a_adapter/facade.py +109 -14
- agentconnect_cli-0.1.0a3/src/agentconnect/a2a_adapter/serve.py +190 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/adapters.py +18 -4
- agentconnect_cli-0.1.0a3/src/agentconnect/api_tls.py +222 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/apiclient.py +14 -4
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/cli.py +2 -1
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/cli_support.py +4 -1
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/config.py +87 -14
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/isolation.py +42 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/mcp/backend.py +11 -8
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/api.py +74 -4
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/runtime.py +1 -1
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/schemas.py +0 -6
- agentconnect_cli-0.1.0a3/src/agentconnect/sockets.py +635 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/webhook.py +14 -1
- agentconnect_cli-0.1.0a1/src/agentconnect/a2a_adapter/serve.py +0 -67
- agentconnect_cli-0.1.0a1/src/agentconnect/sockets.py +0 -86
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/a2a_adapter/__init__.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/a2a_adapter/cards.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/a2a_adapter/convert.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/a2a_adapter/seen.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/adapter.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/backoff.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/callback.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/cli_json.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/clock.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/daemon/__init__.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/deliveries.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/directory_client.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/failpoints.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/identity.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/keystore.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/limits.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/log.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/mcp/__init__.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/mcp/server.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/mcp/session.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/mcp/tools.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/ownerfile.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/payloads.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/policy.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/provision.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/py.typed +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/relay.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/__init__.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/agent.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/engine.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/errors.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/floor.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/groups.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/knocks.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/ledger.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/listing.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/registry.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/runtime/sas.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/sas_emoji.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/shapes.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/sse.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/store.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/tasks.py +0 -0
- {agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/tokens.py +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentconnect-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0a3
|
|
4
4
|
Summary: AgentConnect daemon (agentconnectd) and CLI
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
|
-
Requires-Dist: a2a-sdk[http-server,signing]>=1.2.
|
|
7
|
-
Requires-Dist: agentconnect-core==0.1.
|
|
6
|
+
Requires-Dist: a2a-sdk[http-server,signing]>=1.2.3
|
|
7
|
+
Requires-Dist: agentconnect-core==0.1.0a3
|
|
8
|
+
Requires-Dist: cryptography>=50.0.2
|
|
8
9
|
Requires-Dist: httpx>=0.28.1
|
|
9
10
|
Requires-Dist: keyring>=25.7.0
|
|
10
11
|
Requires-Dist: mcp>=2.3.0
|
|
@@ -12,7 +13,7 @@ Requires-Dist: pyjwt[crypto]>=2.15.1
|
|
|
12
13
|
Requires-Dist: structlog>=26.1.0
|
|
13
14
|
Requires-Dist: typer>=0.27.3
|
|
14
15
|
Requires-Dist: uvicorn>=0.54.0
|
|
15
|
-
Requires-Dist: websockets>=17.
|
|
16
|
+
Requires-Dist: websockets>=17.3
|
|
16
17
|
Requires-Python: >=3.12
|
|
17
18
|
Description-Content-Type: text/markdown
|
|
18
19
|
|
|
@@ -20,8 +21,8 @@ Description-Content-Type: text/markdown
|
|
|
20
21
|
|
|
21
22
|
The AgentConnect daemon (`agentconnectd`) and CLI (`agentconnect`). The
|
|
22
23
|
distribution is `agentconnect-cli`; the command and the import package are
|
|
23
|
-
`agentconnect`. See the repository [README](https://github.com/mbocevski/agent-connect/blob/v0.1.
|
|
24
|
-
[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.0a3/README.md) and
|
|
25
|
+
[SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a3/SPEC.md).
|
|
25
26
|
|
|
26
27
|
```sh
|
|
27
28
|
agentconnect daemon run [--config PATH] [--tcp-port N] # foreground, JSON logs on stderr
|
|
@@ -31,12 +32,12 @@ agentconnect status [--json] # reads the local API
|
|
|
31
32
|
Everything protocol-related is in the runtime, `agentconnect.runtime`
|
|
32
33
|
(`Runtime`, with its engine, local API, adapters and agent-scope
|
|
33
34
|
`AgentApi`). `agentconnectd` (`agentconnect.daemon`) is one host of it; the
|
|
34
|
-
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.0a3/docs/sdk.md))
|
|
35
36
|
is the other. Both run the same checks, and both serve the local API below.
|
|
36
37
|
|
|
37
38
|
The invite lifecycle (`group`, `invite`, `accept`, `groups`, `approvals`,
|
|
38
39
|
`verify`, `leave`, `send`, `events`) is documented in
|
|
39
|
-
[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.0a3/docs/cli.md), with the `--json` schemas and exit codes.
|
|
40
41
|
`approvals approve`, `approvals reject` and `verify` use the human token:
|
|
41
42
|
**never give an agent the human token or let it run those commands for the
|
|
42
43
|
human.**
|
|
@@ -45,7 +46,7 @@ Don't give agents shell or file access to the data directory either: an
|
|
|
45
46
|
agent that can read it can approve joins and mark codes verified as you,
|
|
46
47
|
because the human token is a file there. Agents that need a shell can run
|
|
47
48
|
as another OS user, with the daemon under a user of its own
|
|
48
|
-
([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.0a3/docs/isolation.md)).
|
|
49
50
|
|
|
50
51
|
## What the daemon holds
|
|
51
52
|
|
|
@@ -63,13 +64,14 @@ as another OS user, with the daemon under a user of its own
|
|
|
63
64
|
|
|
64
65
|
The data directory (`~/.local/share/agentconnect`) is 0700 and every file in
|
|
65
66
|
it 0600. Configuration is `~/.config/agentconnect/config.toml`; see
|
|
66
|
-
[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.0a3/docs/config.md) for the keys and the `AC_*` overrides.
|
|
67
68
|
|
|
68
69
|
## Local control API
|
|
69
70
|
|
|
70
71
|
JSON over HTTP/1.1 on a Unix socket in the data directory, or on
|
|
71
|
-
`127.0.0.1:<port
|
|
72
|
-
|
|
72
|
+
`https://127.0.0.1:<port>` (TLS with a certificate the clients pin). Every
|
|
73
|
+
request needs `Authorization: Bearer <token>`.
|
|
74
|
+
[docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a3/docs/api.md) describes the transport, tokens, errors and
|
|
73
75
|
every route with its request and response shapes.
|
|
74
76
|
|
|
75
77
|
Two tokens live in the data directory: `api-token` (agent scope) and
|
|
@@ -97,7 +99,7 @@ repeat a message or an event. Every delivery has a stable `msg_id` and every
|
|
|
97
99
|
event a stable `event_id`; deduplicate by them. Nothing is lost: an event is
|
|
98
100
|
recorded before the adapter hears of it and sent again on restart until
|
|
99
101
|
`on_event` returns (ADR-004).
|
|
100
|
-
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.0a3/docs/adapters/webhook.md)) and the SSE adapter (`GET /v0/events`, [docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a3/docs/api.md#event-stream)) serve headless agents.
|
|
101
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
|
|
102
104
|
and out goes through the safety policy (`agentconnect.policy`) before any
|
|
103
|
-
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.0a3/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.0a3/README.md) and
|
|
6
|
+
[SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a3/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.0a3/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.0a3/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.0a3/docs/isolation.md)).
|
|
31
31
|
|
|
32
32
|
## What the daemon holds
|
|
33
33
|
|
|
@@ -45,13 +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.0a3/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
|
-
`127.0.0.1:<port
|
|
54
|
-
|
|
53
|
+
`https://127.0.0.1:<port>` (TLS with a certificate the clients pin). Every
|
|
54
|
+
request needs `Authorization: Bearer <token>`.
|
|
55
|
+
[docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a3/docs/api.md) describes the transport, tokens, errors and
|
|
55
56
|
every route with its request and response shapes.
|
|
56
57
|
|
|
57
58
|
Two tokens live in the data directory: `api-token` (agent scope) and
|
|
@@ -79,7 +80,7 @@ repeat a message or an event. Every delivery has a stable `msg_id` and every
|
|
|
79
80
|
event a stable `event_id`; deduplicate by them. Nothing is lost: an event is
|
|
80
81
|
recorded before the adapter hears of it and sent again on restart until
|
|
81
82
|
`on_event` returns (ADR-004).
|
|
82
|
-
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.0a3/docs/adapters/webhook.md)) and the SSE adapter (`GET /v0/events`, [docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a3/docs/api.md#event-stream)) serve headless agents.
|
|
83
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
|
|
84
85
|
and out goes through the safety policy (`agentconnect.policy`) before any
|
|
85
|
-
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.0a3/docs/safety.md)).
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "agentconnect-cli"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.0a3"
|
|
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.2.
|
|
10
|
-
"agentconnect-core==0.1.
|
|
9
|
+
"a2a-sdk[http-server,signing]>=1.2.3",
|
|
10
|
+
"agentconnect-core==0.1.0a3",
|
|
11
|
+
"cryptography>=50.0.2",
|
|
11
12
|
"httpx>=0.28.1",
|
|
12
13
|
"keyring>=25.7.0",
|
|
13
14
|
"mcp>=2.3.0",
|
|
@@ -15,7 +16,7 @@ dependencies = [
|
|
|
15
16
|
"structlog>=26.1.0",
|
|
16
17
|
"typer>=0.27.3",
|
|
17
18
|
"uvicorn>=0.54.0",
|
|
18
|
-
"websockets>=17.
|
|
19
|
+
"websockets>=17.3",
|
|
19
20
|
]
|
|
20
21
|
|
|
21
22
|
[project.scripts]
|
|
@@ -28,5 +29,5 @@ workspace = true
|
|
|
28
29
|
module-name = "agentconnect"
|
|
29
30
|
|
|
30
31
|
[build-system]
|
|
31
|
-
requires = ["uv_build>=0.13.
|
|
32
|
+
requires = ["uv_build>=0.13.5,<0.14"]
|
|
32
33
|
build-backend = "uv_build"
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "agentconnect-cli"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.0a3"
|
|
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.2.
|
|
10
|
-
"agentconnect-core==0.1.
|
|
9
|
+
"a2a-sdk[http-server,signing]>=1.2.3",
|
|
10
|
+
"agentconnect-core==0.1.0a3",
|
|
11
|
+
"cryptography>=50.0.2",
|
|
11
12
|
"httpx>=0.28.1",
|
|
12
13
|
"keyring>=25.7.0",
|
|
13
14
|
"mcp>=2.3.0",
|
|
@@ -15,7 +16,7 @@ dependencies = [
|
|
|
15
16
|
"structlog>=26.1.0",
|
|
16
17
|
"typer>=0.27.3",
|
|
17
18
|
"uvicorn>=0.54.0",
|
|
18
|
-
"websockets>=17.
|
|
19
|
+
"websockets>=17.3",
|
|
19
20
|
]
|
|
20
21
|
|
|
21
22
|
[project.scripts]
|
|
@@ -29,5 +30,5 @@ agentconnect-core = { workspace = true }
|
|
|
29
30
|
module-name = "agentconnect"
|
|
30
31
|
|
|
31
32
|
[build-system]
|
|
32
|
-
requires = ["uv_build>=0.13.
|
|
33
|
+
requires = ["uv_build>=0.13.5,<0.14"]
|
|
33
34
|
build-backend = "uv_build"
|
{agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/a2a_adapter/adapter.py
RENAMED
|
@@ -44,6 +44,7 @@ from collections.abc import AsyncIterator, Coroutine, Mapping
|
|
|
44
44
|
from dataclasses import dataclass, field
|
|
45
45
|
from pathlib import Path
|
|
46
46
|
from typing import TYPE_CHECKING, Any
|
|
47
|
+
from urllib.parse import urlsplit
|
|
47
48
|
|
|
48
49
|
import httpx
|
|
49
50
|
from a2a.client import A2ACardResolver, A2AClientError, Client, ClientConfig, ClientFactory
|
|
@@ -73,6 +74,8 @@ from agentconnect.adapter import (
|
|
|
73
74
|
Sender,
|
|
74
75
|
)
|
|
75
76
|
from agentconnect.clock import Clock, unix_seconds
|
|
77
|
+
from agentconnect.isolation import facade_uids, receiver_uids, resolve_gid
|
|
78
|
+
from agentconnect.sockets import PeerMismatchError, receiver_async_transport
|
|
76
79
|
from agentconnect.tasks import cancel_and_wait
|
|
77
80
|
|
|
78
81
|
if TYPE_CHECKING:
|
|
@@ -93,9 +96,18 @@ class A2AOptions:
|
|
|
93
96
|
"""The adapter's configuration (``[a2a]`` in config.toml)."""
|
|
94
97
|
|
|
95
98
|
local_agent_url: str | None = None
|
|
99
|
+
# A Unix socket every request to the local agent goes to, served by one
|
|
100
|
+
# of receiver_uids (SR-10); local_agent_url then gives Host and paths.
|
|
101
|
+
local_agent_socket: Path | None = None
|
|
102
|
+
receiver_uids: frozenset[int] = frozenset()
|
|
96
103
|
local_agent_token: str | None = field(default=None, repr=False)
|
|
97
104
|
card_keys: Mapping[str, PyJWK] = field(default_factory=dict, repr=False)
|
|
98
105
|
facade_port: int | None = None # None: no facade; 0: any free port
|
|
106
|
+
# The facade on a Unix socket instead, open to facade_uids only; created
|
|
107
|
+
# 0660 with the group facade_gid when set (separate-OS-user mode).
|
|
108
|
+
facade_socket: Path | None = None
|
|
109
|
+
facade_uids: frozenset[int] = frozenset()
|
|
110
|
+
facade_gid: int | None = None
|
|
99
111
|
context_messages: int = 20
|
|
100
112
|
frame_text: bool = True
|
|
101
113
|
reply_timeout: float = 600.0
|
|
@@ -109,9 +121,14 @@ class A2AOptions:
|
|
|
109
121
|
token = text or None
|
|
110
122
|
return A2AOptions(
|
|
111
123
|
local_agent_url=config.a2a_local_agent_url,
|
|
124
|
+
local_agent_socket=config.a2a_local_agent_socket,
|
|
125
|
+
receiver_uids=receiver_uids(config),
|
|
112
126
|
local_agent_token=token,
|
|
113
127
|
card_keys=cards.load_jwks(config.a2a_card_keys_file),
|
|
114
128
|
facade_port=config.a2a_facade_port if config.a2a_facade_port > 0 else None,
|
|
129
|
+
facade_socket=config.a2a_facade_socket,
|
|
130
|
+
facade_uids=facade_uids(config),
|
|
131
|
+
facade_gid=resolve_gid(config.isolation_group) if config.isolation else None,
|
|
115
132
|
context_messages=config.a2a_context_messages,
|
|
116
133
|
frame_text=config.a2a_frame_text,
|
|
117
134
|
reply_timeout=float(config.a2a_reply_timeout),
|
|
@@ -286,15 +303,37 @@ class A2AAdapter:
|
|
|
286
303
|
headers = {}
|
|
287
304
|
if self.options.local_agent_token is not None:
|
|
288
305
|
headers["Authorization"] = f"Bearer {self.options.local_agent_token}"
|
|
306
|
+
uds = self.options.local_agent_socket
|
|
307
|
+
transport = (
|
|
308
|
+
None if uds is None else receiver_async_transport(uds, self.options.receiver_uids)
|
|
309
|
+
)
|
|
289
310
|
# No read timeout: a stream may stay quiet while the agent works.
|
|
290
|
-
|
|
311
|
+
# No environment proxies and no redirects: the token and the
|
|
312
|
+
# messages go to local_agent_url (or its socket) and nowhere else.
|
|
313
|
+
self._http = httpx.AsyncClient(
|
|
314
|
+
headers=headers,
|
|
315
|
+
timeout=httpx.Timeout(30.0, read=None),
|
|
316
|
+
transport=transport,
|
|
317
|
+
trust_env=False,
|
|
318
|
+
follow_redirects=False,
|
|
319
|
+
)
|
|
291
320
|
await self._load_card()
|
|
292
|
-
|
|
321
|
+
on_socket = self.options.facade_socket is not None
|
|
322
|
+
if (self.options.facade_port is not None or on_socket) and self.facade is None:
|
|
293
323
|
self.facade_token = self._facade_token()
|
|
294
|
-
facade = Facade(
|
|
324
|
+
facade = Facade(
|
|
325
|
+
self,
|
|
326
|
+
self.facade_token,
|
|
327
|
+
self.options.facade_port or 0,
|
|
328
|
+
path=self.options.facade_socket,
|
|
329
|
+
uids=self.options.facade_uids,
|
|
330
|
+
gid=self.options.facade_gid,
|
|
331
|
+
)
|
|
295
332
|
await facade.start()
|
|
296
333
|
self.facade = facade
|
|
297
|
-
LOG.info(
|
|
334
|
+
LOG.info(
|
|
335
|
+
"a2a_facade_started", transport="unix" if on_socket else "tcp", port=facade.port
|
|
336
|
+
)
|
|
298
337
|
|
|
299
338
|
async def close(self) -> None:
|
|
300
339
|
"""Called by ``Engine.stop``."""
|
|
@@ -451,6 +490,9 @@ class A2AAdapter:
|
|
|
451
490
|
stream = aiter(self._plain.send_message(request))
|
|
452
491
|
first = await anext(stream, None)
|
|
453
492
|
except A2AClientError as e:
|
|
493
|
+
refused = _refusal(e)
|
|
494
|
+
if refused is not None:
|
|
495
|
+
LOG.warning("a2a_receiver_refused", reason=str(refused))
|
|
454
496
|
LOG.warning(
|
|
455
497
|
"a2a_local_unreachable", group=log.hid(group.group_id), error=type(e).__name__
|
|
456
498
|
)
|
|
@@ -543,23 +585,98 @@ class A2AAdapter:
|
|
|
543
585
|
async with asyncio.timeout(CARD_TIMEOUT):
|
|
544
586
|
card = await resolver.get_agent_card()
|
|
545
587
|
except (A2AError, httpx.HTTPError, TimeoutError) as e:
|
|
588
|
+
refused = _refusal(e)
|
|
589
|
+
if refused is not None:
|
|
590
|
+
LOG.warning("a2a_receiver_refused", reason=str(refused))
|
|
546
591
|
LOG.warning("a2a_card_unavailable", error=type(e).__name__)
|
|
547
592
|
return False
|
|
593
|
+
pinned = (
|
|
594
|
+
None if self.options.local_agent_socket is not None else self.options.local_agent_url
|
|
595
|
+
)
|
|
596
|
+
elsewhere = _other_endpoint(card, pinned)
|
|
597
|
+
if elsewhere is not None:
|
|
598
|
+
# On TCP the client would send the token and messages where the
|
|
599
|
+
# card says: only the configured endpoint is trusted (SR-10). On
|
|
600
|
+
# the socket every request goes there, so only an unusable URL is.
|
|
601
|
+
LOG.warning(
|
|
602
|
+
"a2a_card_endpoint_mismatch",
|
|
603
|
+
configured_endpoint=_origin(self.options.local_agent_url),
|
|
604
|
+
card_endpoint=_origin(elsewhere),
|
|
605
|
+
)
|
|
606
|
+
return False
|
|
548
607
|
status = cards.signature_status(card, self.options.card_keys)
|
|
549
608
|
if status == "invalid":
|
|
550
609
|
LOG.warning("a2a_local_card_invalid")
|
|
551
610
|
return False
|
|
611
|
+
try:
|
|
612
|
+
client = ClientFactory(ClientConfig(httpx_client=self._http, streaming=True)).create(
|
|
613
|
+
card
|
|
614
|
+
)
|
|
615
|
+
plain = ClientFactory(ClientConfig(httpx_client=self._http, streaming=False)).create(
|
|
616
|
+
card
|
|
617
|
+
)
|
|
618
|
+
except ValueError:
|
|
619
|
+
# No interface the client can speak (JSON-RPC): unusable, like
|
|
620
|
+
# any other bad card. Whoever answers local_agent_url chooses
|
|
621
|
+
# the card, so it mustn't stop the runtime.
|
|
622
|
+
LOG.warning(
|
|
623
|
+
"a2a_card_unusable",
|
|
624
|
+
reason="no JSON-RPC interface",
|
|
625
|
+
configured_endpoint=_origin(self.options.local_agent_url),
|
|
626
|
+
)
|
|
627
|
+
return False
|
|
552
628
|
self._card = card
|
|
553
629
|
self._card_json = convert.to_json(card)
|
|
554
|
-
self._client =
|
|
555
|
-
card
|
|
556
|
-
)
|
|
557
|
-
self._plain = ClientFactory(ClientConfig(httpx_client=self._http, streaming=False)).create(
|
|
558
|
-
card
|
|
559
|
-
)
|
|
630
|
+
self._client, self._plain = client, plain
|
|
560
631
|
LOG.info("a2a_card_loaded", signature=status, skills=len(card.skills))
|
|
561
632
|
return True
|
|
562
633
|
|
|
563
634
|
def _forget(self, group_id: str) -> None:
|
|
564
635
|
for table in (self._groups, self._cards, self._peers, self._context):
|
|
565
636
|
table.pop(group_id, None)
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
def _refusal(e: BaseException) -> PeerMismatchError | None:
|
|
640
|
+
"""The receiver check behind a client error, if that was the cause."""
|
|
641
|
+
seen: set[int] = set()
|
|
642
|
+
cur: BaseException | None = e
|
|
643
|
+
while cur is not None and id(cur) not in seen:
|
|
644
|
+
if isinstance(cur, PeerMismatchError):
|
|
645
|
+
return cur
|
|
646
|
+
seen.add(id(cur))
|
|
647
|
+
cur = cur.__cause__ or cur.__context__
|
|
648
|
+
return None
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
def _endpoint(url: str) -> tuple[str, str, int | None] | None:
|
|
652
|
+
"""Scheme, host and port of ``url``; ``None`` when it can't be parsed
|
|
653
|
+
(a port out of range or not a number, an IPv6 host without brackets)."""
|
|
654
|
+
try:
|
|
655
|
+
parts = urlsplit(url)
|
|
656
|
+
port = parts.port
|
|
657
|
+
except ValueError:
|
|
658
|
+
return None
|
|
659
|
+
default = {"http": 80, "https": 443}.get(parts.scheme)
|
|
660
|
+
return parts.scheme, (parts.hostname or "").lower(), port or default
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
def _origin(url: str) -> str:
|
|
664
|
+
"""``scheme://host:port`` of ``url``: what is compared, and safe to log
|
|
665
|
+
(no path, query or credentials)."""
|
|
666
|
+
endpoint = _endpoint(url)
|
|
667
|
+
if endpoint is None:
|
|
668
|
+
return "(unparsable)"
|
|
669
|
+
scheme, host, port = endpoint
|
|
670
|
+
return f"{scheme}://{host}:{port}"
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
def _other_endpoint(card: AgentCard, configured: str | None) -> str | None:
|
|
674
|
+
"""An interface URL of ``card`` that can't be parsed or, with a
|
|
675
|
+
``configured`` endpoint, whose scheme, host or port isn't its; else
|
|
676
|
+
``None``."""
|
|
677
|
+
want = None if configured is None else _endpoint(configured)
|
|
678
|
+
for interface in card.supported_interfaces:
|
|
679
|
+
found = _endpoint(interface.url)
|
|
680
|
+
if found is None or (configured is not None and found != want):
|
|
681
|
+
return interface.url
|
|
682
|
+
return None
|
{agentconnect_cli-0.1.0a1 → agentconnect_cli-0.1.0a3}/src/agentconnect/a2a_adapter/facade.py
RENAMED
|
@@ -11,7 +11,10 @@ Each path serves the JSON-RPC binding at its root and its card at
|
|
|
11
11
|
``.well-known/agent-card.json``. Every request needs
|
|
12
12
|
``Authorization: Bearer <a2a-facade-token>``, a loopback client, a ``Host``
|
|
13
13
|
of ``127.0.0.1:<port>`` or ``localhost:<port>``, and no ``Origin`` (a
|
|
14
|
-
browser page can't reach it).
|
|
14
|
+
browser page can't reach it). On a Unix socket (``a2a.facade_socket``)
|
|
15
|
+
instead, a connection is accepted only from an admitted user, checked by
|
|
16
|
+
the kernel's account of its peer before anything is read; the token and
|
|
17
|
+
``Origin`` rules still apply.
|
|
15
18
|
|
|
16
19
|
Tasks are namespaced by group: each group has its own task store, and a
|
|
17
20
|
message's ``contextId`` must be the group (or empty). The facade's task ids
|
|
@@ -26,13 +29,16 @@ from __future__ import annotations
|
|
|
26
29
|
import asyncio
|
|
27
30
|
import contextlib
|
|
28
31
|
import hmac
|
|
32
|
+
import ipaddress
|
|
33
|
+
import logging
|
|
29
34
|
import re
|
|
30
35
|
import time
|
|
31
36
|
from collections import OrderedDict
|
|
32
37
|
from collections.abc import Callable
|
|
33
38
|
from dataclasses import dataclass
|
|
39
|
+
from pathlib import Path
|
|
34
40
|
from typing import TYPE_CHECKING, Any, override
|
|
35
|
-
from urllib.parse import unquote
|
|
41
|
+
from urllib.parse import unquote, urlsplit
|
|
36
42
|
|
|
37
43
|
import httpx
|
|
38
44
|
from a2a.helpers.proto_helpers import new_task
|
|
@@ -55,6 +61,7 @@ from a2a.types import (
|
|
|
55
61
|
Role,
|
|
56
62
|
SendMessageRequest,
|
|
57
63
|
Task,
|
|
64
|
+
TaskPushNotificationConfig,
|
|
58
65
|
TaskState,
|
|
59
66
|
TaskStatus,
|
|
60
67
|
TaskStatusUpdateEvent,
|
|
@@ -65,9 +72,9 @@ from starlette.requests import Request
|
|
|
65
72
|
from starlette.responses import JSONResponse, Response
|
|
66
73
|
from starlette.routing import Route
|
|
67
74
|
|
|
68
|
-
from agentconnect import log
|
|
75
|
+
from agentconnect import isolation, log
|
|
69
76
|
from agentconnect.a2a_adapter import cards, convert
|
|
70
|
-
from agentconnect.a2a_adapter.serve import LoopbackServer
|
|
77
|
+
from agentconnect.a2a_adapter.serve import LoopbackServer, UnixServer
|
|
71
78
|
from agentconnect.adapter import SendReceipt
|
|
72
79
|
|
|
73
80
|
if TYPE_CHECKING:
|
|
@@ -343,18 +350,85 @@ class _GroupApps:
|
|
|
343
350
|
def __init__(self, http: httpx.AsyncClient) -> None:
|
|
344
351
|
self.tasks = InMemoryTaskStore()
|
|
345
352
|
self.push = InMemoryPushNotificationConfigStore()
|
|
346
|
-
self.sender =
|
|
353
|
+
self.sender = _PushSender(http, self.push, push_url_validator=loopback_push_url)
|
|
347
354
|
self.apps: dict[str | None, Any] = {}
|
|
348
355
|
self.handlers: list[DefaultRequestHandler] = []
|
|
349
356
|
|
|
350
357
|
|
|
358
|
+
# a2a-sdk logs a failed push with its URL, query secrets included, and a
|
|
359
|
+
# traceback; the facade logs its own event instead (_PushSender).
|
|
360
|
+
logging.getLogger("a2a.server.tasks.base_push_notification_sender").setLevel(logging.CRITICAL)
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
class _PushSender(BasePushNotificationSender):
|
|
364
|
+
"""a2a-sdk's push sender, logging a failure with the task id only."""
|
|
365
|
+
|
|
366
|
+
@override
|
|
367
|
+
async def _dispatch_notification(
|
|
368
|
+
self, event: Any, push_info: TaskPushNotificationConfig, task_id: str
|
|
369
|
+
) -> bool:
|
|
370
|
+
sent = await super()._dispatch_notification(event, push_info, task_id)
|
|
371
|
+
if not sent:
|
|
372
|
+
LOG.warning("a2a_facade_push_failed", task=task_id)
|
|
373
|
+
return sent
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
async def loopback_push_url(url: str) -> bool:
|
|
377
|
+
"""Whether the facade may send push notifications to ``url``: ``http`` or
|
|
378
|
+
``https`` to a literal loopback address (``127.0.0.0/8`` or ``::1``), with
|
|
379
|
+
no credentials (SR-31). A host name, ``localhost`` included, is refused,
|
|
380
|
+
so nothing is looked up and DNS rebinding has nothing to work with.
|
|
381
|
+
Checked when a config is set and again when a notification is sent. A
|
|
382
|
+
refusal is logged with its reason, never the URL."""
|
|
383
|
+
try:
|
|
384
|
+
parts = urlsplit(url)
|
|
385
|
+
_ = parts.port
|
|
386
|
+
except ValueError:
|
|
387
|
+
reason = "unparsable"
|
|
388
|
+
else:
|
|
389
|
+
reason = _push_url_problem(parts.scheme, parts.netloc, parts.hostname)
|
|
390
|
+
if reason is None:
|
|
391
|
+
return True
|
|
392
|
+
LOG.warning("a2a_facade_push_url_refused", reason=reason)
|
|
393
|
+
return False
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
def _push_url_problem(scheme: str, netloc: str, host: str | None) -> str | None:
|
|
397
|
+
if scheme not in ("http", "https"):
|
|
398
|
+
return "scheme"
|
|
399
|
+
if "@" in netloc:
|
|
400
|
+
return "credentials"
|
|
401
|
+
try:
|
|
402
|
+
address = ipaddress.ip_address(host or "")
|
|
403
|
+
except ValueError:
|
|
404
|
+
return "not an IP address"
|
|
405
|
+
if isinstance(address, ipaddress.IPv6Address) and address.ipv4_mapped is not None:
|
|
406
|
+
return "mapped address"
|
|
407
|
+
return None if address.is_loopback else "not loopback"
|
|
408
|
+
|
|
409
|
+
|
|
351
410
|
class Facade:
|
|
352
|
-
def __init__(
|
|
411
|
+
def __init__( # noqa: PLR0913
|
|
412
|
+
self,
|
|
413
|
+
adapter: A2AAdapter,
|
|
414
|
+
token: str,
|
|
415
|
+
port: int = 0,
|
|
416
|
+
*,
|
|
417
|
+
path: Path | None = None,
|
|
418
|
+
uids: frozenset[int] = frozenset(),
|
|
419
|
+
gid: int | None = None,
|
|
420
|
+
) -> None:
|
|
353
421
|
self.adapter = adapter
|
|
354
422
|
self._token = token
|
|
355
|
-
self.
|
|
423
|
+
self.path = path
|
|
424
|
+
self._uids = uids
|
|
425
|
+
self._server: LoopbackServer = (
|
|
426
|
+
LoopbackServer(self, port) if path is None else UnixServer(self, path, self._admit, gid)
|
|
427
|
+
)
|
|
356
428
|
self._groups: dict[str, _GroupApps] = {}
|
|
357
|
-
|
|
429
|
+
# Push notifications go to the push URL itself: never through an
|
|
430
|
+
# environment proxy, never on to where a redirect points (SR-30).
|
|
431
|
+
self._http = httpx.AsyncClient(timeout=10.0, trust_env=False, follow_redirects=False)
|
|
358
432
|
# msg_id sent by the facade -> the request waiting for replies to it
|
|
359
433
|
self.waiters: dict[str, asyncio.Queue[Delivery]] = {}
|
|
360
434
|
# facade task id -> its peer side
|
|
@@ -377,7 +451,9 @@ class Facade:
|
|
|
377
451
|
return self._server.addresses()
|
|
378
452
|
|
|
379
453
|
def url(self, group_id: str, member: str | None = None) -> str:
|
|
380
|
-
|
|
454
|
+
# On the socket every request goes there; the URL gives the path.
|
|
455
|
+
origin = "http://localhost" if self.path is not None else f"http://127.0.0.1:{self.port}"
|
|
456
|
+
base = f"{origin}/g/{group_id}/"
|
|
381
457
|
return base if member is None else f"{base}m/{member}/"
|
|
382
458
|
|
|
383
459
|
async def start(self) -> None:
|
|
@@ -499,6 +575,7 @@ class Facade:
|
|
|
499
575
|
agent_card=cards.facade_card(self.url(group_id, member), "", "", []),
|
|
500
576
|
push_config_store=group.push,
|
|
501
577
|
push_sender=group.sender,
|
|
578
|
+
push_url_validator=loopback_push_url,
|
|
502
579
|
request_context_builder=_GroupContext(group_id),
|
|
503
580
|
)
|
|
504
581
|
group.handlers.append(handler)
|
|
@@ -512,15 +589,33 @@ class Facade:
|
|
|
512
589
|
group.apps[member] = app
|
|
513
590
|
return app
|
|
514
591
|
|
|
592
|
+
def _admit(self, conn: Any) -> bool:
|
|
593
|
+
"""Unix socket: whether the connection's user may use the facade,
|
|
594
|
+
from the kernel (SO_PEERCRED or getpeereid). ``conn`` is the
|
|
595
|
+
connection's socket, as the event loop's transport gives it."""
|
|
596
|
+
try:
|
|
597
|
+
if conn is None:
|
|
598
|
+
raise OSError("no socket")
|
|
599
|
+
uid = isolation.peer_credentials(conn).uid
|
|
600
|
+
except (OSError, AttributeError):
|
|
601
|
+
LOG.warning("a2a_facade_peer_unknown")
|
|
602
|
+
return False
|
|
603
|
+
if uid not in self._uids:
|
|
604
|
+
LOG.warning("a2a_facade_peer_refused", uid=uid)
|
|
605
|
+
return False
|
|
606
|
+
return True
|
|
607
|
+
|
|
515
608
|
def _refuse(self, scope: dict[str, Any]) -> tuple[int, str] | None:
|
|
516
|
-
client = scope.get("client")
|
|
517
|
-
if not client or client[0] not in ("127.0.0.1", "::1"):
|
|
518
|
-
return 403, "loopback only"
|
|
519
609
|
headers = {k.decode("latin-1").lower(): v.decode("latin-1") for k, v in scope["headers"]}
|
|
520
610
|
if "origin" in headers:
|
|
521
611
|
return 403, "browser requests are refused"
|
|
522
|
-
if
|
|
523
|
-
|
|
612
|
+
if self.path is None:
|
|
613
|
+
# On a port: loopback clients, and no DNS rebinding.
|
|
614
|
+
client = scope.get("client")
|
|
615
|
+
if not client or client[0] not in ("127.0.0.1", "::1"):
|
|
616
|
+
return 403, "loopback only"
|
|
617
|
+
if headers.get("host") not in (f"127.0.0.1:{self.port}", f"localhost:{self.port}"):
|
|
618
|
+
return 403, "bad host"
|
|
524
619
|
scheme, _, token = headers.get("authorization", "").partition(" ")
|
|
525
620
|
if scheme.lower() != "bearer" or not hmac.compare_digest(
|
|
526
621
|
token.encode(), self._token.encode()
|