agentconnect-cli 0.1.0a3__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 (66) hide show
  1. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/PKG-INFO +11 -11
  2. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/README.md +9 -9
  3. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/pyproject.toml +2 -2
  4. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/pyproject.toml.orig +2 -2
  5. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/__init__.py +1 -1
  6. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/adapter.py +11 -4
  7. agentconnect_cli-0.1.0a4/src/agentconnect/a2a_adapter/seen.py +83 -0
  8. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/apiclient.py +9 -0
  9. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/cli.py +41 -6
  10. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/cli_json.py +7 -2
  11. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/cli_support.py +18 -0
  12. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/config.py +23 -1
  13. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/isolation.py +82 -3
  14. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/mcp/tools.py +3 -1
  15. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/relay.py +30 -2
  16. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/agent.py +9 -2
  17. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/api.py +34 -5
  18. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/engine.py +158 -27
  19. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/errors.py +1 -0
  20. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/groups.py +3 -1
  21. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/listing.py +23 -4
  22. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/store.py +21 -0
  23. agentconnect_cli-0.1.0a3/src/agentconnect/a2a_adapter/seen.py +0 -49
  24. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/__init__.py +0 -0
  25. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/cards.py +0 -0
  26. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/convert.py +0 -0
  27. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/facade.py +0 -0
  28. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/a2a_adapter/serve.py +0 -0
  29. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/adapter.py +0 -0
  30. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/adapters.py +0 -0
  31. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/api_tls.py +0 -0
  32. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/backoff.py +0 -0
  33. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/callback.py +0 -0
  34. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/clock.py +0 -0
  35. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/daemon/__init__.py +0 -0
  36. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/deliveries.py +0 -0
  37. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/directory_client.py +0 -0
  38. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/failpoints.py +0 -0
  39. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/identity.py +0 -0
  40. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/keystore.py +0 -0
  41. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/limits.py +0 -0
  42. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/log.py +0 -0
  43. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/mcp/__init__.py +0 -0
  44. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/mcp/backend.py +0 -0
  45. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/mcp/server.py +0 -0
  46. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/mcp/session.py +0 -0
  47. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/ownerfile.py +0 -0
  48. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/payloads.py +0 -0
  49. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/policy.py +0 -0
  50. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/provision.py +0 -0
  51. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/py.typed +0 -0
  52. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/__init__.py +0 -0
  53. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/floor.py +0 -0
  54. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/knocks.py +0 -0
  55. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/ledger.py +0 -0
  56. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/registry.py +0 -0
  57. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/runtime.py +0 -0
  58. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/runtime/sas.py +0 -0
  59. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/sas_emoji.py +0 -0
  60. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/schemas.py +0 -0
  61. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/shapes.py +0 -0
  62. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/sockets.py +0 -0
  63. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/sse.py +0 -0
  64. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/tasks.py +0 -0
  65. {agentconnect_cli-0.1.0a3 → agentconnect_cli-0.1.0a4}/src/agentconnect/tokens.py +0 -0
  66. {agentconnect_cli-0.1.0a3 → 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.0a3
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.0a3
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.0a3/README.md) and
25
- [SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a3/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.0a3/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.0a3/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.0a3/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.0a3/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.0a3/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.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.
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.0a3/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.0a3/README.md) and
6
- [SPEC.md](https://github.com/mbocevski/agent-connect/blob/v0.1.0a3/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.0a3/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.0a3/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.0a3/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.0a3/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.0a3/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.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
+ 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.0a3/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.0a3"
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.0a3",
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.0a3"
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.0a3",
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.0a3"
3
+ __version__ = "0.1.0a4"
@@ -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)
@@ -188,8 +190,13 @@ class A2AAdapter:
188
190
 
189
191
  def bind_store(self, store: Store) -> None:
190
192
  """The daemon's database: the local agent's tasks are kept there,
191
- 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."""
192
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)
193
200
 
194
201
  def bind_clock(self, clock: Clock) -> None:
195
202
  """The runtime's clock, which stamps the task map's entries."""
@@ -230,10 +237,10 @@ class A2AAdapter:
230
237
 
231
238
  @property
232
239
  def _seen(self) -> Seen:
233
- # 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).
234
242
  if self._seen_store is None:
235
- data_dir = self.options.data_dir
236
- self._seen_store = Seen(None if data_dir is None else data_dir / SEEN_FILE)
243
+ self._seen_store = Seen(self._store)
237
244
  return self._seen_store
238
245
 
239
246
  # -- Adapter protocol ----------------------------------------------------
@@ -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."""
@@ -30,8 +30,17 @@ class ApiClient:
30
30
  try:
31
31
  self._token = token_file.read_text(encoding="ascii").strip()
32
32
  except FileNotFoundError:
33
+ if human and (config.data_dir / API_TOKEN_FILE).exists():
34
+ # An agent directory (docs/isolation.md): the daemon is running,
35
+ # and the human token is deliberately not here.
36
+ msg = "no human token in this data directory"
37
+ raise ApiClientError(0, "human_only", msg) from None
33
38
  msg = "no API token: is the daemon running?"
34
39
  raise ApiClientError(0, "not_running", msg) from None
40
+ except PermissionError:
41
+ # The daemon's own data directory, as another OS user.
42
+ msg = f"this OS user can't read {token_file.parent}"
43
+ raise ApiClientError(0, "token_unreadable", msg) from None
35
44
  if config.api_tcp_port:
36
45
  # TLS with the certificate pinned in the data directory.
37
46
  self._transport: httpx.BaseTransport = local_tcp_transport(
@@ -57,6 +57,7 @@ from agentconnect.cli_support import (
57
57
  Sas,
58
58
  clean,
59
59
  connect,
60
+ connect_preferring_human,
60
61
  emit_json,
61
62
  events_after,
62
63
  group_view,
@@ -1069,14 +1070,28 @@ def approvals_list(config: ConfigOpt = None, as_json: JsonOpt = False) -> None:
1069
1070
  """List pending join requests with the joiner's name and fingerprint, knocks on
1070
1071
  your listing, and the messages the safety policy holds (`require_approval`)."""
1071
1072
  with guard(as_json):
1072
- api = connect(config, human=True)
1073
+ scope = "human"
1074
+ try:
1075
+ api = connect(config, human=True)
1076
+ except ApiClientError as e:
1077
+ # An agent's user in the separate-user mode: the route takes its
1078
+ # token too, and shows only the agent's own held sends.
1079
+ if e.code != "human_only":
1080
+ raise
1081
+ api = connect(config)
1082
+ scope = "agent"
1073
1083
  listed = api.request("GET", "/v0/approvals")
1074
1084
  views = [_approval_view(api, a) for a in listed["approvals"]]
1075
1085
  held = list(listed.get("messages", []))
1076
1086
  if as_json:
1077
- emit_json({"approvals": views, "messages": held})
1087
+ emit_json({"scope": scope, "approvals": views, "messages": held})
1078
1088
  return
1079
- if not views:
1089
+ if scope == "agent":
1090
+ # Not "no pending join requests": this token can't know.
1091
+ typer.echo(
1092
+ "(agent token: your own held sends only; join requests and knocks are the human's)"
1093
+ )
1094
+ elif not views:
1080
1095
  typer.echo("No pending join requests or knocks.")
1081
1096
  for v in views:
1082
1097
  _print_approval(v)
@@ -1565,11 +1580,15 @@ def _report_mismatch(api: ApiClient, gid: str, info: dict[str, Any], as_json: bo
1565
1580
  # -- talking ---------------------------------------------------------------------------------
1566
1581
 
1567
1582
 
1568
- @app.command(cls=IdArgsCommand)
1583
+ @app.command(
1584
+ cls=IdArgsCommand,
1585
+ help="Leave a group. The owner must hand over ownership first. Uses the human token "
1586
+ "when you can read it (after the owner asked everyone to leave, leaving is the "
1587
+ "human's answer), else the agent token, which is refused then (`human_decides`).",
1588
+ )
1569
1589
  def leave(group: str, config: ConfigOpt = None, as_json: JsonOpt = False) -> None:
1570
- """Leave a group. The owner must hand over ownership first."""
1571
1590
  with guard(as_json):
1572
- api = connect(config)
1591
+ api = connect_preferring_human(config)
1573
1592
  gid = resolve_group(api, group)
1574
1593
  state = api.request("POST", f"/v0/groups/{gid}/leave")["status"]
1575
1594
  if as_json:
@@ -1580,6 +1599,22 @@ def leave(group: str, config: ConfigOpt = None, as_json: JsonOpt = False) -> Non
1580
1599
  typer.echo("Leaving: the proposal is sent; the other members complete it.")
1581
1600
 
1582
1601
 
1602
+ @app.command(
1603
+ cls=IdArgsCommand,
1604
+ help="Answer the owner's request to close a group by staying in it: your agent may "
1605
+ f"leave on its own again (it can't while the request waits). {HUMAN_ONLY_HELP}",
1606
+ )
1607
+ def stay(group: str, config: ConfigOpt = None, as_json: JsonOpt = False) -> None:
1608
+ with guard(as_json):
1609
+ api = connect(config, human=True)
1610
+ gid = resolve_group(api, group)
1611
+ state = api.request("POST", f"/v0/groups/{gid}/stay")["status"]
1612
+ if as_json:
1613
+ emit_json({"group_id": gid, "status": state})
1614
+ else:
1615
+ typer.echo("Staying in the group.")
1616
+
1617
+
1583
1618
  @app.command(cls=IdArgsCommand)
1584
1619
  def send( # noqa: PLR0913, PLR0917
1585
1620
  group: str,
@@ -239,6 +239,7 @@ SCHEMAS: dict[str, Any] = {
239
239
  },
240
240
  "groups show": GROUP_VIEW,
241
241
  "approvals list": {
242
+ "scope": "str",
242
243
  "approvals": [
243
244
  {
244
245
  "kind": "str",
@@ -334,6 +335,7 @@ SCHEMAS: dict[str, Any] = {
334
335
  ),
335
336
  },
336
337
  "leave": {"group_id": "str", "status": "str"},
338
+ "stay": {"group_id": "str", "status": "str"},
337
339
  "send": {"msg_id": "str", "group_id": "str", "hint": Opt("str")},
338
340
  "listing publish": {
339
341
  "directory": "str",
@@ -403,8 +405,10 @@ NOTES: dict[str, str] = {
403
405
  "its `instances`; `self` marks this one."
404
406
  ),
405
407
  "approvals list": (
406
- "`messages` are the messages the safety policy holds: `direction` is `in` "
407
- "(from `sender`) or `out` (your agent's)."
408
+ "`scope` is `human`, or `agent` when only the agent token is at hand (an agent's "
409
+ "user in the separate-OS-user mode): then the list holds only the agent's own held "
410
+ "sends, whatever waits for the human. `messages` are the messages the safety policy "
411
+ "holds: `direction` is `in` (from `sender`) or `out` (your agent's)."
408
412
  ),
409
413
  "approvals approve": "`status` is `approving`.",
410
414
  "approvals approve (knock)": (
@@ -437,6 +441,7 @@ NOTES: dict[str, str] = {
437
441
  "(SPEC 11)."
438
442
  ),
439
443
  "leave": "`status` is `left` or `leaving`.",
444
+ "stay": "`status` is `staying`.",
440
445
  "listing publish": (
441
446
  "`state` is `published`. `owner_state` is what the directory reported, for "
442
447
  "information only. A directory that didn't answer is `publish_retrying` (exit 1): "
@@ -192,6 +192,13 @@ def map_api_error(e: ApiClientError) -> CliError: # noqa: PLR0911
192
192
  "as the daemon's user, see docs/isolation.md",
193
193
  EXIT_REFUSED,
194
194
  )
195
+ if e.code == "token_unreadable":
196
+ return CliError(
197
+ "token_unreadable",
198
+ f"{e.message}. In the separate-user mode an agent sets AC_DATA_DIR to the agent "
199
+ "directory, and human commands run as the daemon's user, see docs/isolation.md",
200
+ EXIT_REFUSED,
201
+ )
195
202
  if e.code == "peer_mismatch":
196
203
  # Not the daemon's socket; the message names the path and the UIDs.
197
204
  return CliError("peer_mismatch", e.message, EXIT_REFUSED)
@@ -312,6 +319,17 @@ def connect(path: Path | None, *, human: bool = False) -> ApiClient:
312
319
  return ApiClient(load(path), human=human)
313
320
 
314
321
 
322
+ def connect_preferring_human(path: Path | None) -> ApiClient:
323
+ """The human token when this user can read it, else the agent token: for
324
+ an operation either may run whose answer is the human's when it can be
325
+ (leaving after the owner's close, SPEC 7.3)."""
326
+ config = load(path)
327
+ try:
328
+ return ApiClient(config, human=True)
329
+ except (ApiClientError, OSError):
330
+ return ApiClient(config)
331
+
332
+
315
333
  def pause(seconds: float) -> None:
316
334
  """Wait between polls (a seam: tests replace it)."""
317
335
  time.sleep(seconds)
@@ -119,6 +119,11 @@ MAX_JOIN_LEDGER_PER_INVITE = 1024
119
119
  # JoinRequests of one invite that may wait for the human at once (as knocks
120
120
  # per door, SPEC 6.6.3 step 7).
121
121
  MAX_PENDING_JOINS_PER_INVITE = 32
122
+ # Failed JoinRequests of one invite (a bad MAC, or sent from a mailbox other
123
+ # than the one they name, SPEC 6.2 steps 2 and 3) within the window that make
124
+ # the daemon tell the human, at most once per window.
125
+ MAX_FAILED_JOINS_PER_INVITE = 16
126
+ JOIN_FAILURE_WINDOW_SECS = 600
122
127
  # How long a leave waits for a member to commit it (docs/groups.md): at most
123
128
  # the relay's 7-day message lifetime, after which the proposal can't arrive.
124
129
  MIN_LEAVE_TIMEOUT_SECS = 3600
@@ -264,6 +269,7 @@ class Config:
264
269
  policy_audit_max_rows_per_sender: int = DEFAULT_AUDIT_SENDER_ROWS
265
270
  policy_max_pending_joins_per_invite: int = MAX_PENDING_JOINS_PER_INVITE
266
271
  policy_join_ledger_per_invite: int = MAX_JOIN_LEDGER_PER_INVITE
272
+ policy_max_failed_joins_per_invite: int = MAX_FAILED_JOINS_PER_INVITE
267
273
  policy_transcript_max_rows_per_sender: int = KNOB["transcript_max_rows_per_sender"].default
268
274
  policy_transcript_max_group_bytes: int = KNOB["transcript_max_group_bytes"].default
269
275
  policy_audit_retention_days: int = DEFAULT_AUDIT_RETENTION_DAYS
@@ -393,6 +399,18 @@ _POLICY_KEYS: tuple[ConfigKey, ...] = (
393
399
  "most this. Past it, new requests for that invite are dropped and you get an "
394
400
  "`invite_flooded` event; other invites are unaffected.",
395
401
  ),
402
+ ConfigKey(
403
+ "policy.max_failed_joins_per_invite",
404
+ "policy_max_failed_joins_per_invite",
405
+ shown_default(MAX_FAILED_JOINS_PER_INVITE),
406
+ f"Failed join requests for one invite within {JOIN_FAILURE_WINDOW_SECS // 60} "
407
+ f"minutes that get you an `invite_flooded` event, reason `join_failures` (1 to "
408
+ f"{MAX_FAILED_JOINS_PER_INVITE}): a wrong invite MAC, or a request sent from a "
409
+ "mailbox other than the one it names. While they go on, each event waits twice as "
410
+ f"long as the last ({JOIN_FAILURE_WINDOW_SECS // 60} minutes up to a day); a quiet "
411
+ f"{JOIN_FAILURE_WINDOW_SECS // 60} minutes starts over. Failed requests are "
412
+ "dropped; the others are never held back for them.",
413
+ ),
396
414
  )
397
415
 
398
416
  CONFIG_KEYS: tuple[ConfigKey, ...] = (
@@ -400,7 +418,10 @@ CONFIG_KEYS: tuple[ConfigKey, ...] = (
400
418
  "relay.url",
401
419
  "relay_url",
402
420
  "required",
403
- "Relay base URL. `wss://`, or `ws://` for a loopback relay only.",
421
+ "Relay base URL. `wss://`, or `ws://` for a loopback relay only. A remote relay "
422
+ "is reached through `HTTPS_PROXY`, `HTTP_PROXY` or `ALL_PROXY` when one is set "
423
+ "(`NO_PROXY` excepted); a loopback one (`localhost`, 127.0.0.0/8, `::1`) always "
424
+ "directly.",
404
425
  "AC_RELAY_URL",
405
426
  ),
406
427
  ConfigKey(
@@ -978,6 +999,7 @@ def _policy(table: Mapping[str, Any]) -> dict[str, Any]:
978
999
  ("audit_max_rows_per_sender", 100, DEFAULT_AUDIT_SENDER_ROWS),
979
1000
  ("max_pending_joins_per_invite", 1, MAX_PENDING_JOINS_PER_INVITE),
980
1001
  ("join_ledger_per_invite", MIN_JOIN_LEDGER_PER_INVITE, MAX_JOIN_LEDGER_PER_INVITE),
1002
+ ("max_failed_joins_per_invite", 1, MAX_FAILED_JOINS_PER_INVITE),
981
1003
  ):
982
1004
  value = _typed(table, key, int, hi)
983
1005
  if not lo <= value <= hi:
@@ -129,6 +129,11 @@ def _lstat(path: Path) -> os.stat_result | None:
129
129
  return path.lstat()
130
130
  except FileNotFoundError:
131
131
  return None
132
+ except OSError as e:
133
+ # A link loop (ELOOP) or a directory we may not search: a clean
134
+ # refusal, not a traceback.
135
+ msg = f"cannot check {path}: {e.strerror}"
136
+ raise IsolationError(msg) from None
132
137
 
133
138
 
134
139
  def check_private(path: Path, euid: int, *, directory: bool) -> None:
@@ -149,8 +154,10 @@ def check_private(path: Path, euid: int, *, directory: bool) -> None:
149
154
 
150
155
  def check_data_dir(data_dir: Path, euid: int) -> None:
151
156
  """The data directory and its secret files are private to the daemon's
152
- user. A missing directory is fine: the daemon creates it 0700."""
157
+ user, and so is every directory above it. A missing directory is fine:
158
+ the daemon creates it 0700."""
153
159
  check_private(data_dir, euid, directory=True)
160
+ check_parents(data_dir, euid, missing_ok=True)
154
161
  for name in PRIVATE_FILES:
155
162
  check_private(data_dir / name, euid, directory=False)
156
163
 
@@ -174,8 +181,80 @@ def check_agent_dir(agent_dir: Path, euid: int, gid: int) -> None:
174
181
  if st.st_uid != euid or st.st_gid != gid:
175
182
  msg = f"{agent_dir} must be owned by UID {euid} and GID {gid}"
176
183
  raise IsolationError(msg)
177
- if st.st_mode & 0o007 or not st.st_mode & 0o010:
178
- msg = f"{agent_dir} must have mode 0750 or 0710 (group access, none for others)"
184
+ if st.st_mode & 0o027 or not st.st_mode & 0o010:
185
+ # Group write would let an agent user replace the socket (SR-29).
186
+ msg = (
187
+ f"{agent_dir} must have mode 0750 or 0710 "
188
+ "(the group may enter, not write; others nothing)"
189
+ )
190
+ raise IsolationError(msg)
191
+ check_parents(agent_dir, euid)
192
+
193
+
194
+ _MAX_LINKS = 40 # as the kernel's limit on links in one lookup
195
+
196
+
197
+ def check_parents(path: Path, euid: int, *, missing_ok: bool = False) -> None:
198
+ """Every directory that holds a component of ``path``, on the path as
199
+ configured and along each link's target, belongs to ``euid`` or root,
200
+ and only its owner can change entries in it: no group or other write
201
+ unless it is sticky (the OpenSSH secure-path rule). Whoever could
202
+ rename entries there, or repoint a link there, could put their own
203
+ directory in its place (SR-29). With ``missing_ok`` the walk stops at
204
+ the first missing component (the daemon creates the rest itself)."""
205
+ links = [0]
206
+ try:
207
+ _walk(Path.cwd() / path.parent, euid, path, links, missing_ok=missing_ok)
208
+ except OSError as e:
209
+ msg = f"cannot check the directories above {path}: {e.strerror}"
210
+ raise IsolationError(msg) from None
211
+
212
+
213
+ def _walk(at: Path, euid: int, path: Path, links: list[int], *, missing_ok: bool) -> Path | None:
214
+ """Look up ``at`` one component at a time with lstat, as the kernel
215
+ does, checking each directory it passes through; follow links the same
216
+ way. Returns the directory reached, or None when a component is
217
+ missing and ``missing_ok``."""
218
+ real = Path(at.anchor)
219
+ _check_holder(real, euid, path)
220
+ for name in at.parts[1:]:
221
+ if name == "..":
222
+ real = real.parent
223
+ continue
224
+ if name == ".":
225
+ continue
226
+ entry = real / name
227
+ st = _lstat(entry)
228
+ if st is None:
229
+ if missing_ok:
230
+ return None
231
+ msg = f"{entry} is missing"
232
+ raise IsolationError(msg)
233
+ if stat.S_ISLNK(st.st_mode):
234
+ links[0] += 1
235
+ if links[0] > _MAX_LINKS:
236
+ msg = f"too many links above {path}"
237
+ raise IsolationError(msg)
238
+ target = _walk(real / os.readlink(entry), euid, path, links, missing_ok=missing_ok)
239
+ if target is None:
240
+ return None
241
+ real = target
242
+ else:
243
+ real = entry
244
+ _check_holder(real, euid, path)
245
+ return real
246
+
247
+
248
+ def _check_holder(d: Path, euid: int, path: Path) -> None:
249
+ st = _lstat(d)
250
+ if st is None:
251
+ msg = f"{d} is missing"
252
+ raise IsolationError(msg)
253
+ if st.st_uid not in (euid, 0):
254
+ msg = f"{d} must be owned by UID {euid} or root, as every directory above {path}"
255
+ raise IsolationError(msg)
256
+ if st.st_mode & 0o022 and not st.st_mode & stat.S_ISVTX:
257
+ msg = f"{d} must be writable by its owner only (or sticky), as every directory above {path}"
179
258
  raise IsolationError(msg)
180
259
 
181
260
 
@@ -471,7 +471,9 @@ TOOLS: tuple[Tool, ...] = (
471
471
  ),
472
472
  Tool(
473
473
  "agentconnect_leave",
474
- "Leave a group. You stop receiving its messages; rejoining needs a new invite.",
474
+ "Leave a group. You stop receiving its messages; rejoining needs a new invite. "
475
+ "After the owner asked everyone to leave, your human decides: until it answers, "
476
+ "this is refused (human_decides).",
475
477
  _object({"group": _GROUP}, ["group"]),
476
478
  _leave,
477
479
  destructive=True,