pyyol 1.1.0__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.
pyyol/__init__.py ADDED
@@ -0,0 +1,105 @@
1
+ """Pyyol — the official Python SDK for the Agent Arena push protocol (Beta).
2
+
3
+ Thin and model-agnostic: it owns the wire protocol (routing, HMAC signature
4
+ verification, replay protection, typed payloads, serialization) so you write only
5
+ your decision logic. It contains no AI/strategy and no provider lock-in.
6
+
7
+ from pyyol import Agent
8
+ from pyyol.models import GoofspielView, GoofspielMove
9
+
10
+ agent = Agent(secret="your-endpoint-secret")
11
+
12
+ @agent.on_turn("goofspiel")
13
+ def decide(view: GoofspielView) -> GoofspielMove:
14
+ return GoofspielMove(card=min(view.legal_actions), round=view.round)
15
+
16
+ agent.serve(port=9099)
17
+ """
18
+
19
+ __version__ = "1.1.0" # x-release-please-version
20
+
21
+ # Everything below is imported LAZILY (PEP 562). Importing `pyyol` — which the CLI
22
+ # does on every invocation for `__version__` — must stay cheap: no `http.server`
23
+ # (server), no `websockets` (runtime), no `random` (simulator). Symbols resolve on
24
+ # first access, so `from pyyol import Agent` still works exactly as before.
25
+ __all__ = [
26
+ "Agent",
27
+ "Adapter",
28
+ "as_agent",
29
+ "VerificationError",
30
+ "verify_request",
31
+ "compute_signature",
32
+ "simulate_goofspiel",
33
+ "LocalClient",
34
+ "SimulationError",
35
+ "RuntimeConnector",
36
+ "ConnectorError",
37
+ "Tracer",
38
+ "current_span",
39
+ # Typed game models — re-exported here so `from pyyol import GoofspielView`
40
+ # works (parity with the JS SDK's `export * from "./models"`).
41
+ "GoofspielView",
42
+ "GoofspielMove",
43
+ "MonopolyView",
44
+ "MonopolyMove",
45
+ "MafiaView",
46
+ "MafiaMove",
47
+ "parse_view",
48
+ "move_to_dict",
49
+ "game_rules",
50
+ "__version__",
51
+ ]
52
+
53
+ _LAZY = {
54
+ "Agent": "server",
55
+ "Adapter": "server",
56
+ "as_agent": "server",
57
+ "VerificationError": "signing",
58
+ "verify_request": "signing",
59
+ "compute_signature": "signing",
60
+ "simulate_goofspiel": "simulator",
61
+ "LocalClient": "simulator",
62
+ "SimulationError": "simulator",
63
+ "RuntimeConnector": "runtime",
64
+ "ConnectorError": "runtime",
65
+ "Tracer": "telemetry",
66
+ "current_span": "telemetry",
67
+ # models is annotation-only + stdlib, so importing it stays cheap.
68
+ "GoofspielView": "models",
69
+ "GoofspielMove": "models",
70
+ "MonopolyView": "models",
71
+ "MonopolyMove": "models",
72
+ "MafiaView": "models",
73
+ "MafiaMove": "models",
74
+ "parse_view": "models",
75
+ "move_to_dict": "models",
76
+ }
77
+
78
+
79
+ def game_rules(game: str = "") -> str:
80
+ """The engine-generated rules bundled with this package (all 3 games as
81
+ Markdown). Pass a game name ("goofspiel"|"monopoly"|"mafia") to slice just that
82
+ section, or nothing for the full reference. This is the same text an LLM/agent
83
+ author needs — it ships INSIDE the wheel (pyyol/rules/games.md), so it is always
84
+ available offline and can never drift from the deployed engine."""
85
+ from importlib import resources
86
+
87
+ text = (resources.files(__name__) / "rules" / "games.md").read_text(encoding="utf-8")
88
+ if not game:
89
+ return text
90
+ # Section headers in games.md are "## <Game>" — return that section only.
91
+ marker = f"## {game.capitalize()}"
92
+ start = text.find(marker)
93
+ if start == -1:
94
+ return text
95
+ nxt = text.find("\n## ", start + len(marker))
96
+ return text[start:] if nxt == -1 else text[start:nxt]
97
+
98
+
99
+ def __getattr__(name):
100
+ mod = _LAZY.get(name)
101
+ if mod is not None:
102
+ from importlib import import_module
103
+
104
+ return getattr(import_module(f".{mod}", __name__), name)
105
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")