onceonly-sdk 2.0.2__py3-none-any.whl → 3.0.1__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.
@@ -0,0 +1,18 @@
1
+ onceonly/__init__.py,sha256=plE3kBjpF0ssmwiiL1R2EmmlKqbyNhL2nCJHiHi6QSw,855
2
+ onceonly/_http.py,sha256=ijzYTtgz2jSN8j1wKJx6MPbeo8CAG9iWrKAdqnIVwsU,3937
3
+ onceonly/_util.py,sha256=-qVpRL7-IsAM-PgIACujY5WR_aDu9Yz10J_qQCmeYWI,1343
4
+ onceonly/ai.py,sha256=F5tIPvHvkbMyXFnWG0MUio867MpFky8HsZgbEV-cGi8,26101
5
+ onceonly/ai_models.py,sha256=H6nB5GaS-RTo2wRAOxZjS1_5eS-UttatuzbGtu9gJt0,3753
6
+ onceonly/client.py,sha256=veOARzvA3YxOsBEgBjlvVpqfSb1dEI1lAR1iTO_Zzn8,15733
7
+ onceonly/decorators.py,sha256=XTL3BITgVmCDRc4hrzyTNCpQyafvlFAQnjsN1EtEc7Y,8036
8
+ onceonly/exceptions.py,sha256=Issh08A4IHSDaysJhVZNRCU9W_9BfiGt65UHaMhDCs4,1156
9
+ onceonly/governance.py,sha256=-LRkX6kd8CfInlA3TQtLmWmOf5fCZmYQT0o_jQSq_58,19536
10
+ onceonly/models.py,sha256=rdZGQSYX-gzg0nRv2YUALGX5fv4iDw8gWleFABG9QQY,1990
11
+ onceonly/version.py,sha256=E3P6AbnCwaWk6ndR1zNqlOTVebX9z5rv9voltc71dos,22
12
+ onceonly/integrations/__init__.py,sha256=0tk-2HTTsmc42NhWuR_G_Afmz5-5WG8NvmlO7iIPkIY,34
13
+ onceonly/integrations/langchain.py,sha256=cdpHIluddX48uYeDeE1cxmn-arruVdE3k6gvZxYC9z4,5821
14
+ onceonly_sdk-3.0.1.dist-info/licenses/LICENSE,sha256=YQQ8IT_P7hcGmmLFFuOy3eKDZ90e1cqef_okg85oAiQ,129
15
+ onceonly_sdk-3.0.1.dist-info/METADATA,sha256=KmQC-EX4MU1L2IYpM2XPujahV4gwKcTYCt2D4jhW2fw,28163
16
+ onceonly_sdk-3.0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
17
+ onceonly_sdk-3.0.1.dist-info/top_level.txt,sha256=lvz-sHerZcTwlZW-uYoda_wgx62kY07GdtzIdw89hnU,9
18
+ onceonly_sdk-3.0.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,216 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: onceonly-sdk
3
- Version: 2.0.2
4
- Summary: Python SDK for OnceOnly idempotency API
5
- Author-email: OnceOnly <support@onceonly.tech>
6
- License: MIT
7
- Project-URL: Homepage, https://onceonly.tech/
8
- Project-URL: Documentation, https://onceonly.tech/docs/
9
- Project-URL: Repository, https://github.com/mykolademyanov/onceonly-python
10
- Keywords: idempotency,automation,zapier,make,ai-agents
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Operating System :: OS Independent
14
- Requires-Python: >=3.9
15
- Description-Content-Type: text/markdown
16
- License-File: LICENSE
17
- Requires-Dist: httpx>=0.25
18
- Provides-Extra: test
19
- Requires-Dist: pytest>=7.0; extra == "test"
20
- Requires-Dist: pytest-asyncio>=0.23; extra == "test"
21
- Requires-Dist: anyio>=4.0; extra == "test"
22
- Provides-Extra: langchain
23
- Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
24
- Dynamic: license-file
25
-
26
- # OnceOnly Python SDK
27
-
28
- **The Idempotency Layer for AI Agents, Webhooks, and Distributed Systems.**
29
-
30
- OnceOnly is a high-performance Python SDK that ensures **exactly-once execution**.
31
- It prevents duplicate actions (payments, emails, tool calls) in unstable environments like
32
- AI agents, webhooks, retries, or background workers.
33
-
34
-
35
- Website: https://onceonly.tech/ai/
36
- Documentation: https://onceonly.tech/docs/
37
-
38
- [![PyPI version](https://img.shields.io/pypi/v/onceonly-sdk.svg)](https://pypi.org/project/onceonly-sdk/)
39
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
40
- ---
41
-
42
- ## Why duplicates happen
43
-
44
- Duplicate actions are common in modern systems because:
45
- - AI agents retry or re-plan tool calls
46
- - Webhooks are delivered more than once
47
- - Workers crash after side-effects
48
- - Distributed systems replay events
49
-
50
- Without an idempotency layer, the same action may run multiple times.
51
-
52
- OnceOnly is designed to guard side-effects in non-deterministic AI agent loops,
53
- where the same tool call may be executed multiple times.
54
-
55
- ---
56
-
57
- ## Features
58
-
59
- - Sync + Async client (httpx-based)
60
- - Fail-open mode for production safety
61
- - Stable idempotency keys (supports Pydantic & dataclasses)
62
- - Decorators for zero-boilerplate usage
63
- - Native AI API (long-running jobs, local side-effects)
64
- - Optional AI / LangChain integrations
65
-
66
- ---
67
-
68
- ## FAQ
69
-
70
- **Does this prevent duplicate payments or emails?**
71
- Yes. OnceOnly guarantees exactly-once execution for side-effects.
72
-
73
- **Is this a retry library?**
74
- No. Retries still happen — OnceOnly ensures the action itself runs only once.
75
-
76
-
77
- ---
78
-
79
- ## Installation
80
-
81
- ```bash
82
- pip install onceonly-sdk
83
- ```
84
-
85
- ### With LangChain support included:
86
-
87
- ```bash
88
- pip install "onceonly-sdk[langchain]"
89
- ```
90
-
91
- ---
92
-
93
- ## Quick Start (Webhooks / Automations)
94
-
95
- ```python
96
- from onceonly import OnceOnly
97
-
98
- client = OnceOnly(
99
- api_key="once_live_...",
100
- fail_open=True # default: continues if API is down
101
- )
102
-
103
- res = client.check_lock(key="order:123", ttl=300)
104
-
105
- if res.duplicate:
106
- print("Duplicate blocked")
107
- else:
108
- print("First execution")
109
- ```
110
-
111
- Use `check_lock()` for:
112
- - Webhooks
113
- - Make / Zapier scenarios
114
- - Cron jobs
115
- - Distributed workers
116
-
117
- ---
118
-
119
- ## AI Jobs (Server-side)
120
-
121
- Use the AI API for long-running or asynchronous jobs.
122
-
123
- ```python
124
- result = client.ai.run_and_wait(
125
- key="ai:job:daily_summary:2026-01-09",
126
- metadata={"task": "daily_summary", "model": "gpt-4.1"},
127
- timeout=60,
128
- )
129
-
130
- print(result.status)
131
- print(result.result)
132
- ```
133
-
134
- - Charged **once per key**
135
- - Polling is free
136
- - Safe across retries and restarts
137
-
138
- ---
139
-
140
- ## AI Agents / Local Side-Effects
141
-
142
- Use the AI Lease API when your code performs the side-effect locally
143
- (payments, emails, webhooks) but still needs exactly-once guarantees.
144
-
145
- ```python
146
- lease = client.ai.lease(key="ai:agent:charge:user_42:invoice_100", ttl=300)
147
-
148
- if lease["status"] == "acquired":
149
- try:
150
- do_side_effect()
151
- client.ai.complete(key=KEY, lease_id=lease["lease_id"], result={"ok": True})
152
- except Exception:
153
- client.ai.fail(key=KEY, lease_id=lease["lease_id"], error_code="failed")
154
- ```
155
-
156
- ---
157
-
158
- ## LangChain Integration 🤖
159
-
160
- ```python
161
- from onceonly.integrations.langchain import make_idempotent_tool
162
-
163
- tool = make_idempotent_tool(
164
- original_tool,
165
- client=client,
166
- key_prefix="agent:tool"
167
- )
168
- ```
169
-
170
- Repeated tool calls with the same inputs will execute **exactly once**,
171
- even across retries or agent restarts.
172
-
173
- See `examples/ai/` for canonical patterns.
174
-
175
- ---
176
-
177
- ## Decorators
178
-
179
- ```python
180
- from onceonly.decorators import idempotent
181
-
182
- @idempotent(client, ttl=3600)
183
- def process_order(order_id):
184
- ...
185
- ```
186
-
187
- Idempotency keys are generated automatically and remain stable across restarts.
188
-
189
- ---
190
-
191
- ## Fail-Open Mode
192
-
193
- Fail-open is enabled by default.
194
-
195
- Network errors, timeouts, or server errors (5xx) will **not break your application**.
196
- The SDK will allow execution to continue safely.
197
-
198
- Fail-open never applies to:
199
- - Auth errors (401 / 403)
200
- - Plan limits (402)
201
- - Validation errors (422)
202
- - Rate limits (429)
203
-
204
- ---
205
-
206
- ## Support
207
-
208
- Need help?
209
- Email: support@onceonly.tech
210
- Or open an issue on GitHub.
211
-
212
- ---
213
-
214
- ## License
215
-
216
- MIT
@@ -1,17 +0,0 @@
1
- onceonly/__init__.py,sha256=KMS6F4DejM5nI5-gw3UC8SvETnK90oUE9V5pskh--Uw,481
2
- onceonly/_http.py,sha256=bFAgrLv0T7cGFq3LqaQCwEiqx-VfKEiT8jUommmhRws,3240
3
- onceonly/_util.py,sha256=YVdEWn1bvipAzR3g3oXpHmgLiaODwGRB1IGA3gHZ2PM,1273
4
- onceonly/ai.py,sha256=-yaO1ZRlEO-Qqou4P_Q0cemZYwFSIRDM1Lu_AwfF5PY,14578
5
- onceonly/ai_models.py,sha256=7bHYnAavdb3c-4nlh9HgRY18949TgmU9XfXfv3PXQEE,2910
6
- onceonly/client.py,sha256=6DtLdWc-7_bAXsaaewUQUTHVnCkRZGsc-PByMVPRhYY,12838
7
- onceonly/decorators.py,sha256=nP7Wu-RAQQNaTwyOnibzClEgcBJvYheMrG3_KztdlG8,5171
8
- onceonly/exceptions.py,sha256=Issh08A4IHSDaysJhVZNRCU9W_9BfiGt65UHaMhDCs4,1156
9
- onceonly/models.py,sha256=hVEBPgIVZP3ELjWYIFSFCKPzI38t5DA0gio9FvrmHJg,678
10
- onceonly/version.py,sha256=tATvJM5shAzfspHYjdVwpV2w3-gDA119NlEYi5X2lFY,22
11
- onceonly/integrations/__init__.py,sha256=0tk-2HTTsmc42NhWuR_G_Afmz5-5WG8NvmlO7iIPkIY,34
12
- onceonly/integrations/langchain.py,sha256=cdpHIluddX48uYeDeE1cxmn-arruVdE3k6gvZxYC9z4,5821
13
- onceonly_sdk-2.0.2.dist-info/licenses/LICENSE,sha256=YQQ8IT_P7hcGmmLFFuOy3eKDZ90e1cqef_okg85oAiQ,129
14
- onceonly_sdk-2.0.2.dist-info/METADATA,sha256=WzkOQRSbp38Ot2NKPOAOEY8p-_5Wy298bREdx74uD4w,5041
15
- onceonly_sdk-2.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- onceonly_sdk-2.0.2.dist-info/top_level.txt,sha256=lvz-sHerZcTwlZW-uYoda_wgx62kY07GdtzIdw89hnU,9
17
- onceonly_sdk-2.0.2.dist-info/RECORD,,