cowboy-actor-sdk 0.1.2__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 (63) hide show
  1. cowboy_actor_sdk-0.1.2/MANIFEST.in +11 -0
  2. cowboy_actor_sdk-0.1.2/PKG-INFO +77 -0
  3. cowboy_actor_sdk-0.1.2/cowboy_actor_sdk.egg-info/PKG-INFO +77 -0
  4. cowboy_actor_sdk-0.1.2/cowboy_actor_sdk.egg-info/SOURCES.txt +61 -0
  5. cowboy_actor_sdk-0.1.2/cowboy_actor_sdk.egg-info/dependency_links.txt +1 -0
  6. cowboy_actor_sdk-0.1.2/cowboy_actor_sdk.egg-info/requires.txt +1 -0
  7. cowboy_actor_sdk-0.1.2/cowboy_actor_sdk.egg-info/top_level.txt +1 -0
  8. cowboy_actor_sdk-0.1.2/cowboy_sdk/__init__.py +337 -0
  9. cowboy_actor_sdk-0.1.2/cowboy_sdk/__init__.pyi +146 -0
  10. cowboy_actor_sdk-0.1.2/cowboy_sdk/_compiler.py +760 -0
  11. cowboy_actor_sdk-0.1.2/cowboy_sdk/_keccak.py +95 -0
  12. cowboy_actor_sdk-0.1.2/cowboy_sdk/actor.py +1088 -0
  13. cowboy_actor_sdk-0.1.2/cowboy_sdk/actor.pyi +36 -0
  14. cowboy_actor_sdk-0.1.2/cowboy_sdk/bounded_loop.py +195 -0
  15. cowboy_actor_sdk-0.1.2/cowboy_sdk/call.py +238 -0
  16. cowboy_actor_sdk-0.1.2/cowboy_sdk/call.pyi +20 -0
  17. cowboy_actor_sdk-0.1.2/cowboy_sdk/codec.py +388 -0
  18. cowboy_actor_sdk-0.1.2/cowboy_sdk/codec.pyi +9 -0
  19. cowboy_actor_sdk-0.1.2/cowboy_sdk/continuation.py +533 -0
  20. cowboy_actor_sdk-0.1.2/cowboy_sdk/delegation.py +181 -0
  21. cowboy_actor_sdk-0.1.2/cowboy_sdk/errors.py +276 -0
  22. cowboy_actor_sdk-0.1.2/cowboy_sdk/events.py +105 -0
  23. cowboy_actor_sdk-0.1.2/cowboy_sdk/events_v0.py +111 -0
  24. cowboy_actor_sdk-0.1.2/cowboy_sdk/fork.py +83 -0
  25. cowboy_actor_sdk-0.1.2/cowboy_sdk/guards.py +261 -0
  26. cowboy_actor_sdk-0.1.2/cowboy_sdk/handler_mode.py +148 -0
  27. cowboy_actor_sdk-0.1.2/cowboy_sdk/json_codec.py +198 -0
  28. cowboy_actor_sdk-0.1.2/cowboy_sdk/json_codec.pyi +2 -0
  29. cowboy_actor_sdk-0.1.2/cowboy_sdk/mock_host.py +383 -0
  30. cowboy_actor_sdk-0.1.2/cowboy_sdk/models.py +260 -0
  31. cowboy_actor_sdk-0.1.2/cowboy_sdk/offchain.py +45 -0
  32. cowboy_actor_sdk-0.1.2/cowboy_sdk/on_stream.py +47 -0
  33. cowboy_actor_sdk-0.1.2/cowboy_sdk/payload_codec.py +264 -0
  34. cowboy_actor_sdk-0.1.2/cowboy_sdk/payload_codec.pyi +24 -0
  35. cowboy_actor_sdk-0.1.2/cowboy_sdk/permissions.py +702 -0
  36. cowboy_actor_sdk-0.1.2/cowboy_sdk/permissions.pyi +29 -0
  37. cowboy_actor_sdk-0.1.2/cowboy_sdk/pvm_random.py +195 -0
  38. cowboy_actor_sdk-0.1.2/cowboy_sdk/pvm_sys.py +132 -0
  39. cowboy_actor_sdk-0.1.2/cowboy_sdk/pvm_time.py +80 -0
  40. cowboy_actor_sdk-0.1.2/cowboy_sdk/py.typed +0 -0
  41. cowboy_actor_sdk-0.1.2/cowboy_sdk/recipes.py +130 -0
  42. cowboy_actor_sdk-0.1.2/cowboy_sdk/retry.py +159 -0
  43. cowboy_actor_sdk-0.1.2/cowboy_sdk/routes.py +476 -0
  44. cowboy_actor_sdk-0.1.2/cowboy_sdk/runner.py +670 -0
  45. cowboy_actor_sdk-0.1.2/cowboy_sdk/runner_routes.py +504 -0
  46. cowboy_actor_sdk-0.1.2/cowboy_sdk/runtime.py +1317 -0
  47. cowboy_actor_sdk-0.1.2/cowboy_sdk/runtime.pyi +86 -0
  48. cowboy_actor_sdk-0.1.2/cowboy_sdk/send.py +90 -0
  49. cowboy_actor_sdk-0.1.2/cowboy_sdk/send.pyi +12 -0
  50. cowboy_actor_sdk-0.1.2/cowboy_sdk/sorted_map.py +65 -0
  51. cowboy_actor_sdk-0.1.2/cowboy_sdk/taskgroup.py +283 -0
  52. cowboy_actor_sdk-0.1.2/cowboy_sdk/tee.py +101 -0
  53. cowboy_actor_sdk-0.1.2/cowboy_sdk/testing.py +307 -0
  54. cowboy_actor_sdk-0.1.2/cowboy_sdk/testing.pyi +44 -0
  55. cowboy_actor_sdk-0.1.2/cowboy_sdk/timer.py +243 -0
  56. cowboy_actor_sdk-0.1.2/cowboy_sdk/types.py +470 -0
  57. cowboy_actor_sdk-0.1.2/cowboy_sdk/types.pyi +74 -0
  58. cowboy_actor_sdk-0.1.2/cowboy_sdk/verify.py +546 -0
  59. cowboy_actor_sdk-0.1.2/cowboy_sdk/watchtower.py +92 -0
  60. cowboy_actor_sdk-0.1.2/cowboy_sdk/watchtower_codec.py +490 -0
  61. cowboy_actor_sdk-0.1.2/cowboy_sdk_readme.md +60 -0
  62. cowboy_actor_sdk-0.1.2/pyproject.toml +37 -0
  63. cowboy_actor_sdk-0.1.2/setup.cfg +4 -0
@@ -0,0 +1,11 @@
1
+ # Keep build-tooling out of the published sdist (COW-2496).
2
+ #
3
+ # `tests/` holds check_dist.py's own tests and `pytest.ini` roots them. Both
4
+ # are for building/verifying the package, not for consuming it — and the
5
+ # shipped test would be inert anyway, since it imports `../check_dist.py`,
6
+ # which is not part of the distribution. setuptools picks up a top-level
7
+ # `tests/` by default, so it has to be pruned explicitly.
8
+ prune tests
9
+ exclude pytest.ini
10
+ exclude check_dist.py
11
+ exclude sync_sdk.py
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: cowboy-actor-sdk
3
+ Version: 0.1.2
4
+ Summary: SDK for developing Cowboy Actors
5
+ Author: Cowboy Labs
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/cowboyinc/node
8
+ Project-URL: Documentation, https://github.com/cowboyinc/node/blob/main/pvm/docs/cowboy_sdk_developer_manual.md
9
+ Project-URL: Repository, https://github.com/cowboyinc/node.git
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Classifier: Intended Audience :: Developers
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: cbor2>=5.6.0
17
+
18
+ # Cowboy SDK
19
+
20
+ The official Python SDK for developing autonomous actors on the **Cowboy PVM (Python Virtual Machine)**.
21
+
22
+ With this SDK, you can write fully deterministic on-chain Python code that interacts natively with LLMs, APIs, and the broader Cowboy ecosystem.
23
+
24
+ ## Features
25
+
26
+ - **Decentralized AI Agents**: Write prompt chains, FSM-based LLM logic, and MCP integrations directly in Python.
27
+ - **`@runner.continuation`**: Turn Python `async` functions into verified Finite State Machines (FSMs) capable of pausing execution, offloading heavy compute (LLM inference, HTTP requests) to Runners, and seamlessly resuming on the next block.
28
+ - **Robust Determinism**: The SDK strips away standard Python non-determinism (`time`, `random`, `set`) and replaces it with consensus-safe primitives.
29
+ - **CBOR-backed State**: The `CowboyModel` and `self.storage` dict provide automatic schema validation and canonical CBOR serialization for zero-boilerplate state management.
30
+ - **Built-in Async Primitives**: Leverage `TaskGroup` for concurrent Runner tasks, `Retry` for robust backoff logic, and `bounded_loop` to ensure safety limits.
31
+
32
+ ## Quick Start
33
+
34
+ ```shell
35
+ pip install cowboy-actor-sdk
36
+ ```
37
+
38
+ ```python
39
+ from cowboy_sdk import actor, runner, capture
40
+
41
+ @actor
42
+ class MyAgent:
43
+ def init(self, payload):
44
+ self.storage["calls"] = 0
45
+ return b"ok"
46
+
47
+ @runner.continuation
48
+ async def chat(self, msg):
49
+ ctx = capture()
50
+ ctx.prompt = msg.get("message", "Hello")
51
+
52
+ # Off-chain heavy compute (LLM) securely verified via consensus
53
+ result = await runner.llm(ctx.prompt, system_prompt="You are a helpful assistant")
54
+
55
+ # Execution resumes here on the next block
56
+ chat_id = self.storage.get("calls", 0)
57
+ self.storage[f"reply:{chat_id}"] = result
58
+ self.storage["calls"] = chat_id + 1
59
+
60
+ return b"ok"
61
+
62
+ def _a(): return MyAgent()
63
+ def init(p): return _a().init(p)
64
+ def chat(p): return _a().chat(p)
65
+ def chat__resume(p): return _a().chat__resume(p)
66
+ def on_runner_result(p): return _a().on_runner_result(p)
67
+ ```
68
+
69
+ ## Documentation & Tools
70
+
71
+ - **Developer Manual**: [View on GitHub](https://github.com/cowboylabs/cowboy/blob/main/refs/dev_support/cowboy_sdk_developer_manual.md)
72
+ - **Vibe Coding Blueprint (Claude Code)**: Learn how to set up autonomous development without local chain dependencies. [View Guide](https://github.com/cowboylabs/cowboy/blob/main/refs/dev_support/remote_developer_guide.md).
73
+ - **Cowboy CLI**: Pre-compiled binary required to deploy and send transactions. Download from the [GitHub Releases](https://github.com/cowboylabs/cowboy/releases).
74
+
75
+ ## License
76
+
77
+ MIT License. See the repository for details.
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: cowboy-actor-sdk
3
+ Version: 0.1.2
4
+ Summary: SDK for developing Cowboy Actors
5
+ Author: Cowboy Labs
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/cowboyinc/node
8
+ Project-URL: Documentation, https://github.com/cowboyinc/node/blob/main/pvm/docs/cowboy_sdk_developer_manual.md
9
+ Project-URL: Repository, https://github.com/cowboyinc/node.git
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Classifier: Intended Audience :: Developers
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: cbor2>=5.6.0
17
+
18
+ # Cowboy SDK
19
+
20
+ The official Python SDK for developing autonomous actors on the **Cowboy PVM (Python Virtual Machine)**.
21
+
22
+ With this SDK, you can write fully deterministic on-chain Python code that interacts natively with LLMs, APIs, and the broader Cowboy ecosystem.
23
+
24
+ ## Features
25
+
26
+ - **Decentralized AI Agents**: Write prompt chains, FSM-based LLM logic, and MCP integrations directly in Python.
27
+ - **`@runner.continuation`**: Turn Python `async` functions into verified Finite State Machines (FSMs) capable of pausing execution, offloading heavy compute (LLM inference, HTTP requests) to Runners, and seamlessly resuming on the next block.
28
+ - **Robust Determinism**: The SDK strips away standard Python non-determinism (`time`, `random`, `set`) and replaces it with consensus-safe primitives.
29
+ - **CBOR-backed State**: The `CowboyModel` and `self.storage` dict provide automatic schema validation and canonical CBOR serialization for zero-boilerplate state management.
30
+ - **Built-in Async Primitives**: Leverage `TaskGroup` for concurrent Runner tasks, `Retry` for robust backoff logic, and `bounded_loop` to ensure safety limits.
31
+
32
+ ## Quick Start
33
+
34
+ ```shell
35
+ pip install cowboy-actor-sdk
36
+ ```
37
+
38
+ ```python
39
+ from cowboy_sdk import actor, runner, capture
40
+
41
+ @actor
42
+ class MyAgent:
43
+ def init(self, payload):
44
+ self.storage["calls"] = 0
45
+ return b"ok"
46
+
47
+ @runner.continuation
48
+ async def chat(self, msg):
49
+ ctx = capture()
50
+ ctx.prompt = msg.get("message", "Hello")
51
+
52
+ # Off-chain heavy compute (LLM) securely verified via consensus
53
+ result = await runner.llm(ctx.prompt, system_prompt="You are a helpful assistant")
54
+
55
+ # Execution resumes here on the next block
56
+ chat_id = self.storage.get("calls", 0)
57
+ self.storage[f"reply:{chat_id}"] = result
58
+ self.storage["calls"] = chat_id + 1
59
+
60
+ return b"ok"
61
+
62
+ def _a(): return MyAgent()
63
+ def init(p): return _a().init(p)
64
+ def chat(p): return _a().chat(p)
65
+ def chat__resume(p): return _a().chat__resume(p)
66
+ def on_runner_result(p): return _a().on_runner_result(p)
67
+ ```
68
+
69
+ ## Documentation & Tools
70
+
71
+ - **Developer Manual**: [View on GitHub](https://github.com/cowboylabs/cowboy/blob/main/refs/dev_support/cowboy_sdk_developer_manual.md)
72
+ - **Vibe Coding Blueprint (Claude Code)**: Learn how to set up autonomous development without local chain dependencies. [View Guide](https://github.com/cowboylabs/cowboy/blob/main/refs/dev_support/remote_developer_guide.md).
73
+ - **Cowboy CLI**: Pre-compiled binary required to deploy and send transactions. Download from the [GitHub Releases](https://github.com/cowboylabs/cowboy/releases).
74
+
75
+ ## License
76
+
77
+ MIT License. See the repository for details.
@@ -0,0 +1,61 @@
1
+ MANIFEST.in
2
+ cowboy_sdk_readme.md
3
+ pyproject.toml
4
+ cowboy_actor_sdk.egg-info/PKG-INFO
5
+ cowboy_actor_sdk.egg-info/SOURCES.txt
6
+ cowboy_actor_sdk.egg-info/dependency_links.txt
7
+ cowboy_actor_sdk.egg-info/requires.txt
8
+ cowboy_actor_sdk.egg-info/top_level.txt
9
+ cowboy_sdk/__init__.py
10
+ cowboy_sdk/__init__.pyi
11
+ cowboy_sdk/_compiler.py
12
+ cowboy_sdk/_keccak.py
13
+ cowboy_sdk/actor.py
14
+ cowboy_sdk/actor.pyi
15
+ cowboy_sdk/bounded_loop.py
16
+ cowboy_sdk/call.py
17
+ cowboy_sdk/call.pyi
18
+ cowboy_sdk/codec.py
19
+ cowboy_sdk/codec.pyi
20
+ cowboy_sdk/continuation.py
21
+ cowboy_sdk/delegation.py
22
+ cowboy_sdk/errors.py
23
+ cowboy_sdk/events.py
24
+ cowboy_sdk/events_v0.py
25
+ cowboy_sdk/fork.py
26
+ cowboy_sdk/guards.py
27
+ cowboy_sdk/handler_mode.py
28
+ cowboy_sdk/json_codec.py
29
+ cowboy_sdk/json_codec.pyi
30
+ cowboy_sdk/mock_host.py
31
+ cowboy_sdk/models.py
32
+ cowboy_sdk/offchain.py
33
+ cowboy_sdk/on_stream.py
34
+ cowboy_sdk/payload_codec.py
35
+ cowboy_sdk/payload_codec.pyi
36
+ cowboy_sdk/permissions.py
37
+ cowboy_sdk/permissions.pyi
38
+ cowboy_sdk/pvm_random.py
39
+ cowboy_sdk/pvm_sys.py
40
+ cowboy_sdk/pvm_time.py
41
+ cowboy_sdk/py.typed
42
+ cowboy_sdk/recipes.py
43
+ cowboy_sdk/retry.py
44
+ cowboy_sdk/routes.py
45
+ cowboy_sdk/runner.py
46
+ cowboy_sdk/runner_routes.py
47
+ cowboy_sdk/runtime.py
48
+ cowboy_sdk/runtime.pyi
49
+ cowboy_sdk/send.py
50
+ cowboy_sdk/send.pyi
51
+ cowboy_sdk/sorted_map.py
52
+ cowboy_sdk/taskgroup.py
53
+ cowboy_sdk/tee.py
54
+ cowboy_sdk/testing.py
55
+ cowboy_sdk/testing.pyi
56
+ cowboy_sdk/timer.py
57
+ cowboy_sdk/types.py
58
+ cowboy_sdk/types.pyi
59
+ cowboy_sdk/verify.py
60
+ cowboy_sdk/watchtower.py
61
+ cowboy_sdk/watchtower_codec.py
@@ -0,0 +1 @@
1
+ cbor2>=5.6.0
@@ -0,0 +1,337 @@
1
+ """
2
+ cowboy_sdk — Cowboy Actor system Python SDK
3
+
4
+ Version: 0.1.1
5
+ Specification: CIP-6 SDK Specification
6
+
7
+ Design principles (seven invariants):
8
+ I-1 All data crossing trust boundaries uses Canonical CBOR (RFC 8949)
9
+ I-2 SDK public API namespace is unified as cowboy_sdk
10
+ I-3 Continuation on-chain production mode is FSM; Checkpoint is for development/debugging only
11
+ I-4 All security mechanisms (Guard, Reentrancy, BoundedLoop, TypeCheck) are delivered together with features
12
+ I-5 Every new feature ships with deterministic tests; CI verifies cross-platform
13
+ I-6 Floating-point operations globally use SoftFloat (replaced at the PVM layer); SoftFloat = float
14
+ I-7 Version numbers follow SemVer; marked as 0.x before mainnet
15
+
16
+ PVM compatibility golden rules (CIP-6 Appendix A):
17
+ Rule 1: import time is forbidden → use cowboy_sdk.pvm_time
18
+ Rule 2: import random is forbidden → use cowboy_sdk.pvm_random
19
+ Rule 3: hardware FPU float forbidden → SoftFloat = float (replaced at PVM layer)
20
+ Rule 4: set() is forbidden → use ordered_set
21
+ Rule 5: pickle is forbidden → use CBOR (cowboy_sdk.codec)
22
+ Rule 6: call() depth <= 32 → Host API internal counter
23
+ Rule 7: await points <= 8 → FSM compiler static check
24
+ Rule 8: loop await requires @bounded_loop
25
+ Rule 9: capture() must be declared explicitly
26
+ Rule 10: send() is irrevocable
27
+
28
+ Address format (ADDRESS_MIGRATION scheme A):
29
+ All addresses are 20-byte Ethereum-style addresses (secp256k1 + keccak256).
30
+ Two distinct context identities, both 20 bytes: ctx["sender"] is the caller
31
+ (EVM msg.sender) and ctx["actor_addr"] is the actor's own address — do not
32
+ conflate "who called me" with "who I am". Typed accessors return an Address:
33
+ runtime.sender() / runtime.actor_address() (and self.sender on an @actor);
34
+ runtime.get_sender() / runtime.get_actor_address() remain the raw-bytes escape
35
+ hatch. Use the Address class for formatting and validation.
36
+ """
37
+
38
+ __version__ = '0.1.1'
39
+ __author__ = 'Cowboy Chain Team'
40
+ __cip__ = 'CIP-6'
41
+
42
+ # ─── Submodule imports ──────────────────────────────────────────────────────────────────
43
+
44
+ from . import codec
45
+ from . import errors
46
+ from . import pvm_random
47
+ from . import pvm_sys
48
+ from . import pvm_time
49
+ from . import runtime
50
+ from . import events_v0
51
+ from . import events as _events_module
52
+ from . import on_stream as _on_stream_module
53
+
54
+ from . import handler_mode as _handler_mode_module
55
+ from . import continuation
56
+ from . import call as _call_module
57
+ from . import send as _send_module
58
+ from . import fork as _fork_module
59
+ from . import permissions as _permissions_module
60
+ from . import payload_codec as _payload_codec_module
61
+ from . import routes as _routes_module
62
+ from . import actor as _actor_module
63
+ from . import runner
64
+ from . import tee
65
+ from . import watchtower
66
+ from . import sorted_map
67
+ from . import guards
68
+ from . import bounded_loop as _bounded_loop_module
69
+ from . import verify as _verify_module
70
+ from . import retry as _retry_module
71
+ from . import taskgroup as _taskgroup_module
72
+ from . import models as _models_module
73
+ from . import types as _types_module
74
+
75
+ # ─── Top-level public API ────────────────────────────────────────────────────────────────
76
+
77
+ # Continuation
78
+ capture = continuation.capture
79
+ Capture = continuation.Capture
80
+ save_cont = continuation.save_cont
81
+ load_cont = continuation.load_cont
82
+ delete_cont = continuation.delete_cont
83
+
84
+ # Call primitives
85
+ call = _call_module.call
86
+ send = _send_module.send
87
+
88
+ # fork() — self-clone primitive (Unix fork() analogue). See cowboy_sdk.fork.
89
+ fork = _fork_module.fork
90
+
91
+ # Actor system
92
+ actor = _actor_module.actor
93
+ ActorRef = _actor_module.ActorRef
94
+ derive_actor_address = _actor_module.derive_actor_address
95
+
96
+ # Timer-fire handler decorator (CIP-6 / COW-375)
97
+ from .timer import timer
98
+
99
+ # Handler mode decorators
100
+ pure = _handler_mode_module.pure
101
+ deferred = _handler_mode_module.deferred
102
+
103
+ # Cross-actor call permission decorators (CIP-6 §5.6)
104
+ public = _permissions_module.public
105
+ callable_by = _permissions_module.callable_by
106
+ OWNER = _permissions_module.OWNER
107
+ SELF = _permissions_module.SELF
108
+ # Payload codec helpers for handlers declaring an encoded decode=.
109
+ decode_payload = _payload_codec_module.decode_payload
110
+ ok = _payload_codec_module.ok
111
+
112
+ # HTTP route declarations (CIP-15). The verb decorators are NOT exported at
113
+ # the top level — `get`, `post`, etc. shadow common identifiers. Use
114
+ # `from cowboy_sdk.routes import get, post, mount, Pays` directly.
115
+ routes = _routes_module
116
+ Pays = _routes_module.Pays
117
+ mount = _routes_module.mount
118
+
119
+ # Security mechanisms
120
+ reentrancy_guard = guards.reentrancy_guard
121
+ storage_guard = guards.storage_guard
122
+ GuardedValue = guards.GuardedValue
123
+ GuardSet = guards.GuardSet
124
+ bounded_loop = _bounded_loop_module.bounded_loop
125
+ BoundedRange = _bounded_loop_module.BoundedRange
126
+ check_iteration = _bounded_loop_module.check_iteration
127
+
128
+ # Verification
129
+ Verify = _verify_module.Verify
130
+ VerifyBuilder = _verify_module.VerifyBuilder
131
+
132
+ # Error classes (exported at top level)
133
+ from .errors import (
134
+ CowboyError,
135
+ DeterminismError,
136
+ StateConflictError,
137
+ ReentrancyError,
138
+ LoopBoundExceeded,
139
+ CaptureTypeError,
140
+ ContinuationLimitError,
141
+ ContinuationNotFoundError,
142
+ ContinuationCorruptedError,
143
+ ContinuationSizeLimitError,
144
+ ContinuationCountLimitError,
145
+ CycleLimitExceeded,
146
+ CallDepthExceeded,
147
+ RunnerTimeoutError,
148
+ RunnerValidationError,
149
+ DeterministicValidationError,
150
+ CodecError,
151
+ AddressError,
152
+ TokenIdError,
153
+ ActorNotFoundError,
154
+ ActorCallError,
155
+ PurityViolationError,
156
+ PermissionDeniedError,
157
+ )
158
+
159
+ # The off-chain boundary error, bound LAZILY (PEP 562).
160
+ #
161
+ # It lives in `cowboy_sdk.offchain` beside the rules it enforces, and an actor
162
+ # that guards an off-chain await names it on the `cowboy_sdk` import it already
163
+ # writes -- `from cowboy_sdk import actor, codec, public, OffchainError` -- as
164
+ # the same object this package's `offchain` module defines.
165
+ #
166
+ # Binding it eagerly, and listing either name in `__all__`, would charge every
167
+ # actor on the chain for a module almost none of them import. The FSM
168
+ # compiler's per-continuation guard imports `cowboy_sdk` with a `("*",)`
169
+ # fromlist (`pvm/crates/codegen/src/compile.rs`), and that import walks
170
+ # `__all__` once per continuation, so a name added there costs gas in every
171
+ # transaction of every continuation actor, off-chain or not. `__getattr__`
172
+ # resolves the name on first use and caches it in the package namespace, so
173
+ # the second lookup is an ordinary attribute read.
174
+ #
175
+ # Deliberately absent from `__all__` for that reason. Type checkers still see
176
+ # both names, by two different routes: the `.pyi` stub re-exports the class as
177
+ # `from .offchain import OffchainError as OffchainError`, while `offchain`
178
+ # itself needs no stub entry at all -- a submodule of a `py.typed` package
179
+ # resolves from the file system. Checked against the shipped wheel with
180
+ # basedpyright 1.40.0 in strict mode: `from cowboy_sdk import offchain`,
181
+ # `import cowboy_sdk.offchain` and `from cowboy_sdk import OffchainError` all
182
+ # type-check clean. Adding `from . import offchain as offchain` to the stub
183
+ # would be the third route and is the one to avoid: the authoring gate reads
184
+ # an `x as x` form as a claim that `cowboy_sdk.offchain` is an eagerly bound
185
+ # root attribute, which it is not.
186
+ def __getattr__(name):
187
+ # `from .offchain import OffchainError`, NOT `from . import offchain`: the
188
+ # latter asks the import system for an attribute of THIS package, which
189
+ # calls this function again and recurses until the stack gives out. Naming
190
+ # the submodule directly imports it and reads an attribute off it instead,
191
+ # and the import system sets `cowboy_sdk.offchain` as a side effect.
192
+ #
193
+ # Every other name raises, including `offchain` itself, so the ordinary
194
+ # submodule-import fallback handles `from cowboy_sdk import offchain`.
195
+ if name == 'OffchainError':
196
+ # `global`, not `globals()`: the activated environment strips that
197
+ # builtin from actor-reachable code, and a plain global assignment
198
+ # needs no builtin at all.
199
+ global OffchainError
200
+ from .offchain import OffchainError as _boundary_error
201
+ OffchainError = _boundary_error
202
+ return _boundary_error
203
+ raise AttributeError("module 'cowboy_sdk' has no attribute " + repr(name))
204
+
205
+ # Async utilities
206
+ Retry = _retry_module.Retry
207
+ TaskGroup = _taskgroup_module.TaskGroup
208
+
209
+ # Type system
210
+ CowboyModel = _models_module.CowboyModel
211
+ SortedMap = sorted_map.SortedMap
212
+ SoftFloat = _types_module.SoftFloat
213
+ ordered_set = _types_module.ordered_set
214
+ BlockHeight = _types_module.BlockHeight
215
+ Address = _types_module.Address
216
+ to_address_bytes = _types_module.to_address_bytes
217
+ TokenId = _types_module.TokenId
218
+
219
+ # CIP-29 Phase 3 decorators (events_v0 stays — Phase 0 / EventHub still available there)
220
+ emit = _events_module.emit
221
+ on_event = _events_module.on_event
222
+
223
+ # COW-988: CIP-7 Watchtower consume-side decorator (publishing is off-chain).
224
+ on_stream = _on_stream_module.on_stream
225
+
226
+ # ─── __all__ ────────────────────────────────────────────────────────────────────
227
+
228
+ __all__ = [
229
+ # Version
230
+ '__version__',
231
+
232
+ # Submodules
233
+ 'sorted_map',
234
+ 'SortedMap',
235
+ 'codec',
236
+ 'errors',
237
+ 'continuation',
238
+ 'runner',
239
+ 'watchtower',
240
+ 'pvm_random',
241
+ 'pvm_sys',
242
+ 'pvm_time',
243
+ 'runtime',
244
+ 'events_v0',
245
+ 'events',
246
+
247
+ # Top-level functions
248
+ 'capture',
249
+ 'call',
250
+ 'send',
251
+ 'fork',
252
+
253
+ # Actor system
254
+ 'actor',
255
+ 'ActorRef',
256
+ 'derive_actor_address',
257
+ 'timer',
258
+
259
+ # Handler mode decorators
260
+ 'pure',
261
+ 'deferred',
262
+
263
+ # Permission decorators
264
+ 'public',
265
+ 'callable_by',
266
+ 'OWNER',
267
+ 'SELF',
268
+ 'decode_payload',
269
+ 'ok',
270
+
271
+ # HTTP routes (CIP-15) — module + Pays + mount only at top level;
272
+ # import @get/@post/@put/@patch/@delete/@route from cowboy_sdk.routes.
273
+ 'routes',
274
+ 'Pays',
275
+ 'mount',
276
+
277
+ # Security mechanisms
278
+ 'reentrancy_guard',
279
+ 'storage_guard',
280
+ 'GuardedValue',
281
+ 'GuardSet',
282
+ 'bounded_loop',
283
+ 'BoundedRange',
284
+ 'check_iteration',
285
+
286
+ # Verification
287
+ 'Verify',
288
+
289
+ # Async utilities
290
+ 'Retry',
291
+ 'TaskGroup',
292
+
293
+ # Type system
294
+ 'CowboyModel',
295
+ 'SoftFloat',
296
+ 'ordered_set',
297
+ 'BlockHeight',
298
+ 'Address',
299
+ 'to_address_bytes',
300
+ 'TokenId',
301
+
302
+ # CIP-29 Phase 3 decorators
303
+ 'emit',
304
+ 'on_event',
305
+
306
+ # CIP-7 Watchtower consume-side decorator (COW-988)
307
+ 'on_stream',
308
+
309
+ # Continuation
310
+ 'Capture',
311
+ 'save_cont',
312
+ 'load_cont',
313
+ 'delete_cont',
314
+
315
+ # Error classes
316
+ 'errors',
317
+ 'CowboyError',
318
+ 'DeterminismError',
319
+ 'StateConflictError',
320
+ 'ReentrancyError',
321
+ 'LoopBoundExceeded',
322
+ 'CaptureTypeError',
323
+ 'ContinuationLimitError',
324
+ 'ContinuationNotFoundError',
325
+ 'ContinuationCorruptedError',
326
+ 'ContinuationSizeLimitError',
327
+ 'ContinuationCountLimitError',
328
+ 'RunnerTimeoutError',
329
+ 'RunnerValidationError',
330
+ 'CodecError',
331
+ 'AddressError',
332
+ 'TokenIdError',
333
+ 'ActorNotFoundError',
334
+ 'ActorCallError',
335
+ 'PurityViolationError',
336
+ 'PermissionDeniedError',
337
+ ]