agentconnect-cli 0.1.0a1__py3-none-any.whl

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 (64) hide show
  1. agentconnect/__init__.py +3 -0
  2. agentconnect/a2a_adapter/__init__.py +6 -0
  3. agentconnect/a2a_adapter/adapter.py +565 -0
  4. agentconnect/a2a_adapter/cards.py +149 -0
  5. agentconnect/a2a_adapter/convert.py +157 -0
  6. agentconnect/a2a_adapter/facade.py +560 -0
  7. agentconnect/a2a_adapter/seen.py +49 -0
  8. agentconnect/a2a_adapter/serve.py +67 -0
  9. agentconnect/adapter.py +319 -0
  10. agentconnect/adapters.py +52 -0
  11. agentconnect/apiclient.py +51 -0
  12. agentconnect/backoff.py +42 -0
  13. agentconnect/callback.py +314 -0
  14. agentconnect/cli.py +2324 -0
  15. agentconnect/cli_json.py +470 -0
  16. agentconnect/cli_support.py +444 -0
  17. agentconnect/clock.py +161 -0
  18. agentconnect/config.py +1213 -0
  19. agentconnect/daemon/__init__.py +41 -0
  20. agentconnect/deliveries.py +295 -0
  21. agentconnect/directory_client.py +255 -0
  22. agentconnect/failpoints.py +99 -0
  23. agentconnect/identity.py +111 -0
  24. agentconnect/isolation.py +345 -0
  25. agentconnect/keystore.py +279 -0
  26. agentconnect/limits.py +457 -0
  27. agentconnect/log.py +143 -0
  28. agentconnect/mcp/__init__.py +30 -0
  29. agentconnect/mcp/backend.py +405 -0
  30. agentconnect/mcp/server.py +382 -0
  31. agentconnect/mcp/session.py +373 -0
  32. agentconnect/mcp/tools.py +583 -0
  33. agentconnect/ownerfile.py +238 -0
  34. agentconnect/payloads.py +109 -0
  35. agentconnect/policy.py +1066 -0
  36. agentconnect/provision.py +239 -0
  37. agentconnect/py.typed +0 -0
  38. agentconnect/relay.py +405 -0
  39. agentconnect/runtime/__init__.py +46 -0
  40. agentconnect/runtime/agent.py +225 -0
  41. agentconnect/runtime/api.py +2043 -0
  42. agentconnect/runtime/engine.py +5359 -0
  43. agentconnect/runtime/errors.py +47 -0
  44. agentconnect/runtime/floor.py +649 -0
  45. agentconnect/runtime/groups.py +1351 -0
  46. agentconnect/runtime/knocks.py +1422 -0
  47. agentconnect/runtime/ledger.py +94 -0
  48. agentconnect/runtime/listing.py +1307 -0
  49. agentconnect/runtime/registry.py +53 -0
  50. agentconnect/runtime/runtime.py +158 -0
  51. agentconnect/runtime/sas.py +1002 -0
  52. agentconnect/sas_emoji.py +83 -0
  53. agentconnect/schemas.py +381 -0
  54. agentconnect/shapes.py +56 -0
  55. agentconnect/sockets.py +86 -0
  56. agentconnect/sse.py +234 -0
  57. agentconnect/store.py +3282 -0
  58. agentconnect/tasks.py +35 -0
  59. agentconnect/tokens.py +63 -0
  60. agentconnect/webhook.py +199 -0
  61. agentconnect_cli-0.1.0a1.dist-info/METADATA +103 -0
  62. agentconnect_cli-0.1.0a1.dist-info/RECORD +64 -0
  63. agentconnect_cli-0.1.0a1.dist-info/WHEEL +4 -0
  64. agentconnect_cli-0.1.0a1.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,47 @@
1
+ """Errors of the runtime's operations, and how each maps to an API answer.
2
+
3
+ The local API and the embedded SDK both turn a failed operation into the
4
+ same ``(status, code, message)``, so a caller sees the same error whichever
5
+ host it uses.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from agentconnect.relay import RelayError
11
+ from agentconnect.runtime.engine import DaemonError
12
+
13
+ ERROR_STATUS = {
14
+ "bad_request": 400,
15
+ "wrong_relay": 400,
16
+ "forbidden": 403,
17
+ "not_permitted": 403,
18
+ "not_found": 404,
19
+ "group_full": 409,
20
+ "expired": 409,
21
+ "stale_epoch": 409,
22
+ "invite_not_open": 409,
23
+ "not_moderated": 409,
24
+ "too_large": 413,
25
+ "rate_limited": 429,
26
+ "relay": 502,
27
+ }
28
+
29
+
30
+ class ApiError(Exception):
31
+ """A refused request: an HTTP ``status`` and a short ``code``."""
32
+
33
+ def __init__(self, status: int, code: str, message: str) -> None:
34
+ super().__init__(message)
35
+ self.status, self.code = status, code
36
+
37
+
38
+ def error_reply(e: Exception) -> tuple[int, str, str] | None:
39
+ """``(status, code, message)`` for an operation's error, or ``None`` for
40
+ an unexpected one (a bug: the caller logs it and answers 500)."""
41
+ if isinstance(e, ApiError):
42
+ return e.status, e.code, str(e)
43
+ if isinstance(e, DaemonError):
44
+ return ERROR_STATUS.get(e.code, 409), e.code, str(e)
45
+ if isinstance(e, RelayError):
46
+ return 502, e.code, str(e)
47
+ return None