actionbox-sdk 0.1.7__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Suson Sapkota
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,205 @@
1
+ Metadata-Version: 2.4
2
+ Name: actionbox-sdk
3
+ Version: 0.1.7
4
+ Summary: Python client for Actionbox durable human decisions
5
+ License-Expression: MIT
6
+ Project-URL: Documentation, https://actionbox.cloud/docs
7
+ Project-URL: API, https://api.actionbox.cloud/docs
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: httpx>=0.27
12
+ Dynamic: license-file
13
+
14
+ <img src="https://actionbox.cloud/appbox.svg" width="64" alt="Actionbox logo">
15
+
16
+ # Actionbox Python SDK
17
+
18
+ Actionbox gives backend services a durable, server-authoritative way to ask a
19
+ human for a decision and continue when that decision is available. This package
20
+ is the typed Python client for creating, resolving, and waiting on Actions,
21
+ plus managing source-scoped heartbeat Watches.
22
+
23
+ ## Documentation
24
+
25
+ - [Actionbox documentation](https://actionbox.cloud/docs)
26
+
27
+ ## Requirements
28
+
29
+ - Python 3.11 or newer
30
+ - An Actionbox Source API key, supplied through `ACTIONBOX_API_KEY`
31
+
32
+ Keep API keys and Watch capability URLs on trusted servers, workers, or CI
33
+ jobs. Do not put this SDK or its credentials in browser code.
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ pip install actionbox-sdk
39
+ ```
40
+
41
+ The distribution is named `actionbox-sdk` so it does not conflict with the
42
+ Actionbox CLI distribution on PyPI. The Python import remains `actionbox`.
43
+
44
+ ```python
45
+ import os
46
+ from actionbox import Actionbox
47
+
48
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
49
+ decision = client.ask(
50
+ title="Deploy to production?",
51
+ options=["Approve", "Reject"],
52
+ callback_url="https://ci.example.com/actionbox",
53
+ )
54
+ print(decision)
55
+ ```
56
+
57
+ The SDK uses the hosted production API at `https://api.actionbox.cloud` by
58
+ default. Customer integrations should use that default and only pass
59
+ `base_url` in maintainer-controlled test environments.
60
+
61
+ `ask(..., wait=False)` returns an `Action`; `Action.wait()` polls the server and leaves the Action open when the local timeout expires. The concise single-choice API returns the selected option ID as a string.
62
+
63
+ ## Typed interactions and responses
64
+
65
+ The SDK exports typed interaction and response contracts that match the REST API. Use an explicit typed interaction with `create` or `ask` when the human response is more than a single choice:
66
+
67
+ ```python
68
+ from actionbox import Actionbox, BooleanInteraction
69
+
70
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
71
+ action = client.create(
72
+ title="Deploy configuration",
73
+ interaction=BooleanInteraction(
74
+ type="boolean",
75
+ label="Deploy now?",
76
+ true_label="Deploy",
77
+ false_label="Hold",
78
+ ),
79
+ )
80
+ resolved = client.resolve(
81
+ action.id,
82
+ response={"type": "boolean", "value": True},
83
+ reason="Approved by release manager",
84
+ )
85
+ print(resolved.response) # {"type": "boolean", "value": True}
86
+ ```
87
+
88
+ The available interaction types are `boolean`, `single_choice`, `multi_choice`, `text`, `integer`, `number`, `rating`, and `form`. Form fields use the same typed field shapes and are returned as `{"type": "form", "values": {...}}`. Create inputs also accept bounded developer `context` blocks and an explicit typed `on_expire` fallback; omitting it returns `expired` without inventing a response.
89
+
90
+ `resolve` supports concise single-choice syntax and generic typed input:
91
+
92
+ ```python
93
+ client.resolve(action.id, "approve") # single-choice shorthand
94
+ client.resolve(action.id, {"response": {"type": "text", "value": "ship"}})
95
+ client.actions.resolve(action.id, response={"type": "number", "value": 4.5})
96
+ ```
97
+
98
+ `Action.interaction` and `Action.response` expose the canonical typed wire values. `options`, `option_id`, `ask(..., options=[...])`, and string decision results are first-class single-choice conveniences.
99
+
100
+ ## Optional decision context
101
+
102
+ Keep simple Actions unchanged. For higher-impact reviews, use a helper that
103
+ builds the same generic structured context accepted by the REST API:
104
+
105
+ ```python
106
+ from actionbox import deployment_decision_context
107
+
108
+ action = client.create(
109
+ title="Deploy 2.18.0?",
110
+ decision_class="production_deployment",
111
+ decision_context=deployment_decision_context(
112
+ reason="Release passed staging.",
113
+ proposed_change="Deploy 2.18.0 to production.",
114
+ risk_level="high",
115
+ reversibility="reversible",
116
+ rollback_plan="Restore the previous image.",
117
+ ),
118
+ )
119
+ ```
120
+
121
+ The generic, refund, database-change, and access-request helpers emit this same
122
+ wire shape; they do not create server-side template types.
123
+
124
+ ## Agent framework integrations
125
+
126
+ The OpenAI Agents SDK and LangGraph keep their own paused run state; Actionbox
127
+ supplies the durable human request and typed response. The repository includes
128
+ tested examples for both patterns:
129
+
130
+ - OpenAI Agents: map `result.interruptions` to Actions, apply each decision to
131
+ `result.to_state()`, then resume the original agent.
132
+ - LangGraph: create Actions after interrupts surface to the graph driver, then
133
+ resume the same checkpoint and `thread_id` with `Command(resume=...)`.
134
+
135
+ See `integrations/agent_frameworks/` in the Actionbox repository. No additional
136
+ Actionbox endpoint or framework-owned state migration is required.
137
+
138
+ ## Execution outcomes
139
+
140
+ After carrying out an approved operation, report its real result from the
141
+ resolved Action snapshot:
142
+
143
+ ```python
144
+ outcome = resolved.report_outcome(
145
+ "success",
146
+ duration_ms=48_312,
147
+ rollback=False,
148
+ )
149
+ ```
150
+
151
+ The SDK sends the Action's exact version and fingerprint. Exact retries are
152
+ safe; Actionbox rejects a conflicting second outcome.
153
+
154
+ ## Agent Runs
155
+
156
+ Group an agent task and its Actions without managing another framework:
157
+
158
+ ```python
159
+ run = client.runs.start(
160
+ external_id="checkout-fix-42",
161
+ agent_name="codex",
162
+ title="Fix checkout deadlock",
163
+ stall_after_seconds=900,
164
+ )
165
+ run.progress(stage="tests", checkpoint="test-184")
166
+ action = client.create(title="Approve staging migration", run_id=run.id)
167
+ run.complete()
168
+ ```
169
+
170
+ The SDK handles progress sequence numbers. Runs are optional; standalone
171
+ Actions continue to work exactly as before. When `stall_after_seconds` is set,
172
+ unchanged status/stage/checkpoint updates do not reset the timer. Actionbox
173
+ creates one ordinary Action if progress stalls and resolves it when progress
174
+ changes or the Run completes; `waiting` pauses the timer.
175
+
176
+ ## Heartbeat Watches
177
+
178
+ Source credentials can create and list Watches scoped to that Source. The raw heartbeat URL is returned only by creation:
179
+
180
+ ```python
181
+ from actionbox import Actionbox, send_heartbeat
182
+
183
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
184
+ watch = client.watches.create(
185
+ source_id="src_…",
186
+ name="Nightly backup",
187
+ schedule_type="interval",
188
+ interval_seconds=3600,
189
+ grace_seconds=60,
190
+ signal_method="post",
191
+ )
192
+ send_heartbeat(watch.heartbeat_url, "start")
193
+ ```
194
+
195
+ Use `send_heartbeat` for `ping`, `start`, `success`, or `fail`; it always sends
196
+ POST. `signal_method="post"` prevents link previewers and security scanners
197
+ from accidentally recording a heartbeat with GET. The
198
+ source-scoped resource also exposes `client.watches.pause(id)`,
199
+ `resume(id)`, `rotate_token(id)`, and `archive(id)`; only create/rotate return
200
+ a raw URL. Store capability URLs in a secret manager; Watch details and
201
+ exports never return them.
202
+
203
+ ## License
204
+
205
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,192 @@
1
+ <img src="https://actionbox.cloud/appbox.svg" width="64" alt="Actionbox logo">
2
+
3
+ # Actionbox Python SDK
4
+
5
+ Actionbox gives backend services a durable, server-authoritative way to ask a
6
+ human for a decision and continue when that decision is available. This package
7
+ is the typed Python client for creating, resolving, and waiting on Actions,
8
+ plus managing source-scoped heartbeat Watches.
9
+
10
+ ## Documentation
11
+
12
+ - [Actionbox documentation](https://actionbox.cloud/docs)
13
+
14
+ ## Requirements
15
+
16
+ - Python 3.11 or newer
17
+ - An Actionbox Source API key, supplied through `ACTIONBOX_API_KEY`
18
+
19
+ Keep API keys and Watch capability URLs on trusted servers, workers, or CI
20
+ jobs. Do not put this SDK or its credentials in browser code.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install actionbox-sdk
26
+ ```
27
+
28
+ The distribution is named `actionbox-sdk` so it does not conflict with the
29
+ Actionbox CLI distribution on PyPI. The Python import remains `actionbox`.
30
+
31
+ ```python
32
+ import os
33
+ from actionbox import Actionbox
34
+
35
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
36
+ decision = client.ask(
37
+ title="Deploy to production?",
38
+ options=["Approve", "Reject"],
39
+ callback_url="https://ci.example.com/actionbox",
40
+ )
41
+ print(decision)
42
+ ```
43
+
44
+ The SDK uses the hosted production API at `https://api.actionbox.cloud` by
45
+ default. Customer integrations should use that default and only pass
46
+ `base_url` in maintainer-controlled test environments.
47
+
48
+ `ask(..., wait=False)` returns an `Action`; `Action.wait()` polls the server and leaves the Action open when the local timeout expires. The concise single-choice API returns the selected option ID as a string.
49
+
50
+ ## Typed interactions and responses
51
+
52
+ The SDK exports typed interaction and response contracts that match the REST API. Use an explicit typed interaction with `create` or `ask` when the human response is more than a single choice:
53
+
54
+ ```python
55
+ from actionbox import Actionbox, BooleanInteraction
56
+
57
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
58
+ action = client.create(
59
+ title="Deploy configuration",
60
+ interaction=BooleanInteraction(
61
+ type="boolean",
62
+ label="Deploy now?",
63
+ true_label="Deploy",
64
+ false_label="Hold",
65
+ ),
66
+ )
67
+ resolved = client.resolve(
68
+ action.id,
69
+ response={"type": "boolean", "value": True},
70
+ reason="Approved by release manager",
71
+ )
72
+ print(resolved.response) # {"type": "boolean", "value": True}
73
+ ```
74
+
75
+ The available interaction types are `boolean`, `single_choice`, `multi_choice`, `text`, `integer`, `number`, `rating`, and `form`. Form fields use the same typed field shapes and are returned as `{"type": "form", "values": {...}}`. Create inputs also accept bounded developer `context` blocks and an explicit typed `on_expire` fallback; omitting it returns `expired` without inventing a response.
76
+
77
+ `resolve` supports concise single-choice syntax and generic typed input:
78
+
79
+ ```python
80
+ client.resolve(action.id, "approve") # single-choice shorthand
81
+ client.resolve(action.id, {"response": {"type": "text", "value": "ship"}})
82
+ client.actions.resolve(action.id, response={"type": "number", "value": 4.5})
83
+ ```
84
+
85
+ `Action.interaction` and `Action.response` expose the canonical typed wire values. `options`, `option_id`, `ask(..., options=[...])`, and string decision results are first-class single-choice conveniences.
86
+
87
+ ## Optional decision context
88
+
89
+ Keep simple Actions unchanged. For higher-impact reviews, use a helper that
90
+ builds the same generic structured context accepted by the REST API:
91
+
92
+ ```python
93
+ from actionbox import deployment_decision_context
94
+
95
+ action = client.create(
96
+ title="Deploy 2.18.0?",
97
+ decision_class="production_deployment",
98
+ decision_context=deployment_decision_context(
99
+ reason="Release passed staging.",
100
+ proposed_change="Deploy 2.18.0 to production.",
101
+ risk_level="high",
102
+ reversibility="reversible",
103
+ rollback_plan="Restore the previous image.",
104
+ ),
105
+ )
106
+ ```
107
+
108
+ The generic, refund, database-change, and access-request helpers emit this same
109
+ wire shape; they do not create server-side template types.
110
+
111
+ ## Agent framework integrations
112
+
113
+ The OpenAI Agents SDK and LangGraph keep their own paused run state; Actionbox
114
+ supplies the durable human request and typed response. The repository includes
115
+ tested examples for both patterns:
116
+
117
+ - OpenAI Agents: map `result.interruptions` to Actions, apply each decision to
118
+ `result.to_state()`, then resume the original agent.
119
+ - LangGraph: create Actions after interrupts surface to the graph driver, then
120
+ resume the same checkpoint and `thread_id` with `Command(resume=...)`.
121
+
122
+ See `integrations/agent_frameworks/` in the Actionbox repository. No additional
123
+ Actionbox endpoint or framework-owned state migration is required.
124
+
125
+ ## Execution outcomes
126
+
127
+ After carrying out an approved operation, report its real result from the
128
+ resolved Action snapshot:
129
+
130
+ ```python
131
+ outcome = resolved.report_outcome(
132
+ "success",
133
+ duration_ms=48_312,
134
+ rollback=False,
135
+ )
136
+ ```
137
+
138
+ The SDK sends the Action's exact version and fingerprint. Exact retries are
139
+ safe; Actionbox rejects a conflicting second outcome.
140
+
141
+ ## Agent Runs
142
+
143
+ Group an agent task and its Actions without managing another framework:
144
+
145
+ ```python
146
+ run = client.runs.start(
147
+ external_id="checkout-fix-42",
148
+ agent_name="codex",
149
+ title="Fix checkout deadlock",
150
+ stall_after_seconds=900,
151
+ )
152
+ run.progress(stage="tests", checkpoint="test-184")
153
+ action = client.create(title="Approve staging migration", run_id=run.id)
154
+ run.complete()
155
+ ```
156
+
157
+ The SDK handles progress sequence numbers. Runs are optional; standalone
158
+ Actions continue to work exactly as before. When `stall_after_seconds` is set,
159
+ unchanged status/stage/checkpoint updates do not reset the timer. Actionbox
160
+ creates one ordinary Action if progress stalls and resolves it when progress
161
+ changes or the Run completes; `waiting` pauses the timer.
162
+
163
+ ## Heartbeat Watches
164
+
165
+ Source credentials can create and list Watches scoped to that Source. The raw heartbeat URL is returned only by creation:
166
+
167
+ ```python
168
+ from actionbox import Actionbox, send_heartbeat
169
+
170
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
171
+ watch = client.watches.create(
172
+ source_id="src_…",
173
+ name="Nightly backup",
174
+ schedule_type="interval",
175
+ interval_seconds=3600,
176
+ grace_seconds=60,
177
+ signal_method="post",
178
+ )
179
+ send_heartbeat(watch.heartbeat_url, "start")
180
+ ```
181
+
182
+ Use `send_heartbeat` for `ping`, `start`, `success`, or `fail`; it always sends
183
+ POST. `signal_method="post"` prevents link previewers and security scanners
184
+ from accidentally recording a heartbeat with GET. The
185
+ source-scoped resource also exposes `client.watches.pause(id)`,
186
+ `resume(id)`, `rotate_token(id)`, and `archive(id)`; only create/rotate return
187
+ a raw URL. Store capability URLs in a secret manager; Watch details and
188
+ exports never return them.
189
+
190
+ ## License
191
+
192
+ MIT. See [LICENSE](./LICENSE).