agentconnect-cli 0.1.0a2__tar.gz → 0.1.0a4__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.
Files changed (67) hide show
  1. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/PKG-INFO +11 -11
  2. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/README.md +9 -9
  3. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/pyproject.toml +2 -2
  4. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/pyproject.toml.orig +2 -2
  5. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/__init__.py +1 -1
  6. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/adapter.py +51 -14
  7. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/facade.py +109 -14
  8. agentconnect_cli-0.1.0a4/src/agentconnect/a2a_adapter/seen.py +83 -0
  9. agentconnect_cli-0.1.0a4/src/agentconnect/a2a_adapter/serve.py +190 -0
  10. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/apiclient.py +9 -0
  11. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/cli.py +41 -6
  12. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/cli_json.py +7 -2
  13. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/cli_support.py +18 -0
  14. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/config.py +56 -6
  15. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/isolation.py +103 -3
  16. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/mcp/tools.py +3 -1
  17. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/relay.py +30 -2
  18. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/agent.py +9 -2
  19. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/api.py +34 -5
  20. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/engine.py +158 -27
  21. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/errors.py +1 -0
  22. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/groups.py +3 -1
  23. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/listing.py +23 -4
  24. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/schemas.py +0 -6
  25. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/store.py +21 -0
  26. agentconnect_cli-0.1.0a2/src/agentconnect/a2a_adapter/seen.py +0 -49
  27. agentconnect_cli-0.1.0a2/src/agentconnect/a2a_adapter/serve.py +0 -67
  28. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/__init__.py +0 -0
  29. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/cards.py +0 -0
  30. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/convert.py +0 -0
  31. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/adapter.py +0 -0
  32. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/adapters.py +0 -0
  33. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/api_tls.py +0 -0
  34. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/backoff.py +0 -0
  35. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/callback.py +0 -0
  36. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/clock.py +0 -0
  37. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/daemon/__init__.py +0 -0
  38. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/deliveries.py +0 -0
  39. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/directory_client.py +0 -0
  40. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/failpoints.py +0 -0
  41. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/identity.py +0 -0
  42. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/keystore.py +0 -0
  43. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/limits.py +0 -0
  44. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/log.py +0 -0
  45. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/mcp/__init__.py +0 -0
  46. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/mcp/backend.py +0 -0
  47. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/mcp/server.py +0 -0
  48. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/mcp/session.py +0 -0
  49. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/ownerfile.py +0 -0
  50. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/payloads.py +0 -0
  51. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/policy.py +0 -0
  52. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/provision.py +0 -0
  53. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/py.typed +0 -0
  54. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/__init__.py +0 -0
  55. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/floor.py +0 -0
  56. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/knocks.py +0 -0
  57. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/ledger.py +0 -0
  58. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/registry.py +0 -0
  59. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/runtime.py +0 -0
  60. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/sas.py +0 -0
  61. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/sas_emoji.py +0 -0
  62. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/shapes.py +0 -0
  63. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/sockets.py +0 -0
  64. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/sse.py +0 -0
  65. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/tasks.py +0 -0
  66. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/tokens.py +0 -0
  67. {agentconnect_cli-0.1.0a2 → agentconnect_cli-0.1.0a4}/src/agentconnect/webhook.py +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentconnect-cli
3
- Version: 0.1.0a2
3
+ Version: 0.1.0a4
4
4
  Summary: AgentConnect daemon (agentconnectd) and CLI
5
5
  License-Expression: Apache-2.0
6
6
  Requires-Dist: a2a-sdk[http-server,signing]>=1.2.3
7
- Requires-Dist: agentconnect-core==0.1.0a2
7
+ Requires-Dist: agentconnect-core==0.1.0a4
8
8
  Requires-Dist: cryptography>=50.0.2
9
9
  Requires-Dist: httpx>=0.28.1
10
10
  Requires-Dist: keyring>=25.7.0
@@ -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.0a2/README.md) and
25
- [SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a2/SPEC.md).
24
+ `agentconnect`. See the repository [README](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/README.md) and
25
+ [SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/sdk.md))
35
+ Python SDK's embedded mode (`AgentConnect.embedded`, [docs/sdk.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/cli.md), with the `--json` schemas and exit codes.
40
+ [docs/cli.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/isolation.md)).
49
+ ([docs/isolation.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/config.md) for the keys and the `AC_*` overrides.
67
+ [docs/config.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/api.md) describes the transport, tokens, errors and
74
+ [docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/adapters/webhook.md)) and the SSE adapter (`GET /v0/events`, [docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a2/docs/api.md#event-stream)) serve headless agents.
102
+ The webhook adapter ([docs/adapters/webhook.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/docs/adapters/webhook.md)) and the SSE adapter (`GET /v0/events`, [docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/safety.md)).
105
+ adapter sees it ([docs/safety.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/README.md) and
6
- [SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a2/SPEC.md).
5
+ `agentconnect`. See the repository [README](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/README.md) and
6
+ [SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/sdk.md))
16
+ Python SDK's embedded mode (`AgentConnect.embedded`, [docs/sdk.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/cli.md), with the `--json` schemas and exit codes.
21
+ [docs/cli.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/isolation.md)).
30
+ ([docs/isolation.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/config.md) for the keys and the `AC_*` overrides.
48
+ [docs/config.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/api.md) describes the transport, tokens, errors and
55
+ [docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/adapters/webhook.md)) and the SSE adapter (`GET /v0/events`, [docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a2/docs/api.md#event-stream)) serve headless agents.
83
+ The webhook adapter ([docs/adapters/webhook.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/docs/adapters/webhook.md)) and the SSE adapter (`GET /v0/events`, [docs/api.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/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.0a2/docs/safety.md)).
86
+ adapter sees it ([docs/safety.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a4/docs/safety.md)).
@@ -1,13 +1,13 @@
1
1
  [project]
2
2
  name = "agentconnect-cli"
3
- version = "0.1.0a2"
3
+ version = "0.1.0a4"
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
9
  "a2a-sdk[http-server,signing]>=1.2.3",
10
- "agentconnect-core==0.1.0a2",
10
+ "agentconnect-core==0.1.0a4",
11
11
  "cryptography>=50.0.2",
12
12
  "httpx>=0.28.1",
13
13
  "keyring>=25.7.0",
@@ -1,13 +1,13 @@
1
1
  [project]
2
2
  name = "agentconnect-cli"
3
- version = "0.1.0a2"
3
+ version = "0.1.0a4"
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
9
  "a2a-sdk[http-server,signing]>=1.2.3",
10
- "agentconnect-core==0.1.0a2",
10
+ "agentconnect-core==0.1.0a4",
11
11
  "cryptography>=50.0.2",
12
12
  "httpx>=0.28.1",
13
13
  "keyring>=25.7.0",
@@ -1,3 +1,3 @@
1
1
  """AgentConnect daemon and CLI."""
2
2
 
3
- __version__ = "0.1.0a2"
3
+ __version__ = "0.1.0a4"
@@ -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 receiver_uids
77
+ from agentconnect.isolation import facade_uids, receiver_uids, resolve_gid
78
78
  from agentconnect.sockets import PeerMismatchError, receiver_async_transport
79
79
  from agentconnect.tasks import cancel_and_wait
80
80
 
@@ -84,6 +84,8 @@ if TYPE_CHECKING:
84
84
 
85
85
  LOG = log.get("a2a")
86
86
  FACADE_TOKEN_FILE = "a2a-facade-token" # noqa: S105 - a file name
87
+ # Where older daemons kept the seen set, in plain SQLite: moved into the
88
+ # encrypted database and deleted on first use.
87
89
  SEEN_FILE = "a2a-seen.db"
88
90
  MAX_CONTEXT_ENTRY = 64 * 1024 # bytes of JSON; bigger context entries are summarised
89
91
  MAX_TASKS = 1024 # local agent tasks kept in memory (a cache of the database's)
@@ -103,6 +105,11 @@ class A2AOptions:
103
105
  local_agent_token: str | None = field(default=None, repr=False)
104
106
  card_keys: Mapping[str, PyJWK] = field(default_factory=dict, repr=False)
105
107
  facade_port: int | None = None # None: no facade; 0: any free port
108
+ # The facade on a Unix socket instead, open to facade_uids only; created
109
+ # 0660 with the group facade_gid when set (separate-OS-user mode).
110
+ facade_socket: Path | None = None
111
+ facade_uids: frozenset[int] = frozenset()
112
+ facade_gid: int | None = None
106
113
  context_messages: int = 20
107
114
  frame_text: bool = True
108
115
  reply_timeout: float = 600.0
@@ -121,6 +128,9 @@ class A2AOptions:
121
128
  local_agent_token=token,
122
129
  card_keys=cards.load_jwks(config.a2a_card_keys_file),
123
130
  facade_port=config.a2a_facade_port if config.a2a_facade_port > 0 else None,
131
+ facade_socket=config.a2a_facade_socket,
132
+ facade_uids=facade_uids(config),
133
+ facade_gid=resolve_gid(config.isolation_group) if config.isolation else None,
124
134
  context_messages=config.a2a_context_messages,
125
135
  frame_text=config.a2a_frame_text,
126
136
  reply_timeout=float(config.a2a_reply_timeout),
@@ -180,8 +190,13 @@ class A2AAdapter:
180
190
 
181
191
  def bind_store(self, store: Store) -> None:
182
192
  """The daemon's database: the local agent's tasks are kept there,
183
- so a follow-up or a cancel after a restart still finds its task."""
193
+ so a follow-up or a cancel after a restart still finds its task, and
194
+ so is the seen set. An older daemon's plain seen file is taken over
195
+ here, at start, rather than inside the first delivery."""
184
196
  self._store = store
197
+ data_dir = self.options.data_dir
198
+ legacy = None if data_dir is None else data_dir / SEEN_FILE
199
+ self._seen_store = Seen(store, legacy)
185
200
 
186
201
  def bind_clock(self, clock: Clock) -> None:
187
202
  """The runtime's clock, which stamps the task map's entries."""
@@ -222,10 +237,10 @@ class A2AAdapter:
222
237
 
223
238
  @property
224
239
  def _seen(self) -> Seen:
225
- # Opened on first use: the daemon creates the data directory.
240
+ # In the daemon's encrypted database once it is bound (bind_store);
241
+ # in memory without it (unit use).
226
242
  if self._seen_store is None:
227
- data_dir = self.options.data_dir
228
- self._seen_store = Seen(None if data_dir is None else data_dir / SEEN_FILE)
243
+ self._seen_store = Seen(self._store)
229
244
  return self._seen_store
230
245
 
231
246
  # -- Adapter protocol ----------------------------------------------------
@@ -310,12 +325,22 @@ class A2AAdapter:
310
325
  follow_redirects=False,
311
326
  )
312
327
  await self._load_card()
313
- if self.options.facade_port is not None and self.facade is None:
328
+ on_socket = self.options.facade_socket is not None
329
+ if (self.options.facade_port is not None or on_socket) and self.facade is None:
314
330
  self.facade_token = self._facade_token()
315
- facade = Facade(self, self.facade_token, self.options.facade_port)
331
+ facade = Facade(
332
+ self,
333
+ self.facade_token,
334
+ self.options.facade_port or 0,
335
+ path=self.options.facade_socket,
336
+ uids=self.options.facade_uids,
337
+ gid=self.options.facade_gid,
338
+ )
316
339
  await facade.start()
317
340
  self.facade = facade
318
- LOG.info("a2a_facade_started", port=facade.port)
341
+ LOG.info(
342
+ "a2a_facade_started", transport="unix" if on_socket else "tcp", port=facade.port
343
+ )
319
344
 
320
345
  async def close(self) -> None:
321
346
  """Called by ``Engine.stop``."""
@@ -590,14 +615,26 @@ class A2AAdapter:
590
615
  if status == "invalid":
591
616
  LOG.warning("a2a_local_card_invalid")
592
617
  return False
618
+ try:
619
+ client = ClientFactory(ClientConfig(httpx_client=self._http, streaming=True)).create(
620
+ card
621
+ )
622
+ plain = ClientFactory(ClientConfig(httpx_client=self._http, streaming=False)).create(
623
+ card
624
+ )
625
+ except ValueError:
626
+ # No interface the client can speak (JSON-RPC): unusable, like
627
+ # any other bad card. Whoever answers local_agent_url chooses
628
+ # the card, so it mustn't stop the runtime.
629
+ LOG.warning(
630
+ "a2a_card_unusable",
631
+ reason="no JSON-RPC interface",
632
+ configured_endpoint=_origin(self.options.local_agent_url),
633
+ )
634
+ return False
593
635
  self._card = card
594
636
  self._card_json = convert.to_json(card)
595
- self._client = ClientFactory(ClientConfig(httpx_client=self._http, streaming=True)).create(
596
- card
597
- )
598
- self._plain = ClientFactory(ClientConfig(httpx_client=self._http, streaming=False)).create(
599
- card
600
- )
637
+ self._client, self._plain = client, plain
601
638
  LOG.info("a2a_card_loaded", signature=status, skills=len(card.skills))
602
639
  return True
603
640
 
@@ -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 = BasePushNotificationSender(http, self.push)
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__(self, adapter: A2AAdapter, token: str, port: int) -> None:
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._server = LoopbackServer(self, port)
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
- self._http = httpx.AsyncClient(timeout=10.0)
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
- base = f"http://127.0.0.1:{self.port}/g/{group_id}/"
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 headers.get("host") not in (f"127.0.0.1:{self.port}", f"localhost:{self.port}"):
523
- return 403, "bad host"
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()
@@ -0,0 +1,83 @@
1
+ """What the adapter has already handled, so at-least-once redelivery (ADR-004)
2
+ never reaches the A2A agent twice.
3
+
4
+ Keys are ``msg_id``s and ``event_id``s. Only their SHA-256 is stored, in the
5
+ daemon's encrypted database (SPEC 12: there is no unencrypted on-disk mode),
6
+ and the newest :data:`LIMIT` entries are kept. Without the daemon's database
7
+ (unit use) the set lives in memory. Older daemons kept it in a plain SQLite
8
+ file in the data directory: its entries move into the database and the file
9
+ is deleted.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import hashlib
15
+ import sqlite3
16
+ from collections import OrderedDict
17
+ from pathlib import Path
18
+ from typing import TYPE_CHECKING
19
+
20
+ if TYPE_CHECKING:
21
+ from agentconnect.store import Store
22
+
23
+ LIMIT = 50_000
24
+ PRUNE_EVERY = 1_000
25
+
26
+
27
+ class Seen:
28
+ def __init__(self, store: Store | None, legacy: Path | None = None) -> None:
29
+ self._store = store
30
+ self._memory: OrderedDict[str, None] = OrderedDict()
31
+ self._n = 0 if store is None else store.a2a_seen_last()
32
+ if store is not None and legacy is not None:
33
+ self._import(legacy)
34
+
35
+ def _import(self, legacy: Path) -> None:
36
+ """Move an older daemon's plain file into the database, oldest
37
+ first and in one transaction (row by row it took minutes for a full
38
+ file), then delete it with its journal files."""
39
+ if legacy.exists() and self._store is not None:
40
+ try:
41
+ # An escaped URI: a `#` or `?` in the path would cut a raw one
42
+ # short and open another file.
43
+ old = sqlite3.connect(legacy.resolve().as_uri() + "?mode=ro", uri=True)
44
+ try:
45
+ rows = old.execute("SELECT h FROM seen ORDER BY n").fetchall()
46
+ finally:
47
+ old.close()
48
+ except sqlite3.Error:
49
+ rows = [] # unreadable: at worst one redelivery reaches the agent
50
+ with self._store.tx():
51
+ for (h,) in rows[-LIMIT:]:
52
+ self._n += 1
53
+ self._store.a2a_seen_add(str(h), self._n)
54
+ self._store.a2a_seen_prune(self._n - LIMIT)
55
+ for suffix in ("", "-wal", "-shm", "-journal"):
56
+ legacy.with_name(legacy.name + suffix).unlink(missing_ok=True)
57
+
58
+ @staticmethod
59
+ def _h(kind: str, key: str) -> str:
60
+ return hashlib.sha256(f"{kind}\0{key}".encode()).hexdigest()
61
+
62
+ def has(self, kind: str, key: str) -> bool:
63
+ h = self._h(kind, key)
64
+ if self._store is None:
65
+ return h in self._memory
66
+ return self._store.a2a_seen_has(h)
67
+
68
+ def add(self, kind: str, key: str) -> None:
69
+ self._put(self._h(kind, key))
70
+
71
+ def _put(self, h: str) -> None:
72
+ self._n += 1
73
+ if self._store is None:
74
+ self._memory[h] = None
75
+ while len(self._memory) > LIMIT:
76
+ self._memory.popitem(last=False)
77
+ return
78
+ self._store.a2a_seen_add(h, self._n)
79
+ if self._n % PRUNE_EVERY == 0:
80
+ self._store.a2a_seen_prune(self._n - LIMIT)
81
+
82
+ def close(self) -> None:
83
+ """Nothing to close: the daemon owns its database."""