actionbox-sdk 0.1.6__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,167 @@
1
+ Metadata-Version: 2.4
2
+ Name: actionbox-sdk
3
+ Version: 0.1.6
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
+ ## Execution outcomes
101
+
102
+ After carrying out an approved operation, report its real result from the
103
+ resolved Action snapshot:
104
+
105
+ ```python
106
+ outcome = resolved.report_outcome(
107
+ "success",
108
+ duration_ms=48_312,
109
+ rollback=False,
110
+ )
111
+ ```
112
+
113
+ The SDK sends the Action's exact version and fingerprint. Exact retries are
114
+ safe; Actionbox rejects a conflicting second outcome.
115
+
116
+ ## Agent Runs
117
+
118
+ Group an agent task and its Actions without managing another framework:
119
+
120
+ ```python
121
+ run = client.runs.start(
122
+ external_id="checkout-fix-42",
123
+ agent_name="codex",
124
+ title="Fix checkout deadlock",
125
+ stall_after_seconds=900,
126
+ )
127
+ run.progress(stage="tests", checkpoint="test-184")
128
+ action = client.create(title="Approve staging migration", run_id=run.id)
129
+ run.complete()
130
+ ```
131
+
132
+ The SDK handles progress sequence numbers. Runs are optional; standalone
133
+ Actions continue to work exactly as before. When `stall_after_seconds` is set,
134
+ unchanged status/stage/checkpoint updates do not reset the timer. Actionbox
135
+ creates one ordinary Action if progress stalls and resolves it when progress
136
+ changes or the Run completes; `waiting` pauses the timer.
137
+
138
+ ## Heartbeat Watches
139
+
140
+ Source credentials can create and list Watches scoped to that Source. The raw heartbeat URL is returned only by creation:
141
+
142
+ ```python
143
+ from actionbox import Actionbox, send_heartbeat
144
+
145
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
146
+ watch = client.watches.create(
147
+ source_id="src_…",
148
+ name="Nightly backup",
149
+ schedule_type="interval",
150
+ interval_seconds=3600,
151
+ grace_seconds=60,
152
+ signal_method="post",
153
+ )
154
+ send_heartbeat(watch.heartbeat_url, "start")
155
+ ```
156
+
157
+ Use `send_heartbeat` for `ping`, `start`, `success`, or `fail`; it always sends
158
+ POST. `signal_method="post"` prevents link previewers and security scanners
159
+ from accidentally recording a heartbeat with GET. The
160
+ source-scoped resource also exposes `client.watches.pause(id)`,
161
+ `resume(id)`, `rotate_token(id)`, and `archive(id)`; only create/rotate return
162
+ a raw URL. Store capability URLs in a secret manager; Watch details and
163
+ exports never return them.
164
+
165
+ ## License
166
+
167
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,154 @@
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
+ ## Execution outcomes
88
+
89
+ After carrying out an approved operation, report its real result from the
90
+ resolved Action snapshot:
91
+
92
+ ```python
93
+ outcome = resolved.report_outcome(
94
+ "success",
95
+ duration_ms=48_312,
96
+ rollback=False,
97
+ )
98
+ ```
99
+
100
+ The SDK sends the Action's exact version and fingerprint. Exact retries are
101
+ safe; Actionbox rejects a conflicting second outcome.
102
+
103
+ ## Agent Runs
104
+
105
+ Group an agent task and its Actions without managing another framework:
106
+
107
+ ```python
108
+ run = client.runs.start(
109
+ external_id="checkout-fix-42",
110
+ agent_name="codex",
111
+ title="Fix checkout deadlock",
112
+ stall_after_seconds=900,
113
+ )
114
+ run.progress(stage="tests", checkpoint="test-184")
115
+ action = client.create(title="Approve staging migration", run_id=run.id)
116
+ run.complete()
117
+ ```
118
+
119
+ The SDK handles progress sequence numbers. Runs are optional; standalone
120
+ Actions continue to work exactly as before. When `stall_after_seconds` is set,
121
+ unchanged status/stage/checkpoint updates do not reset the timer. Actionbox
122
+ creates one ordinary Action if progress stalls and resolves it when progress
123
+ changes or the Run completes; `waiting` pauses the timer.
124
+
125
+ ## Heartbeat Watches
126
+
127
+ Source credentials can create and list Watches scoped to that Source. The raw heartbeat URL is returned only by creation:
128
+
129
+ ```python
130
+ from actionbox import Actionbox, send_heartbeat
131
+
132
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
133
+ watch = client.watches.create(
134
+ source_id="src_…",
135
+ name="Nightly backup",
136
+ schedule_type="interval",
137
+ interval_seconds=3600,
138
+ grace_seconds=60,
139
+ signal_method="post",
140
+ )
141
+ send_heartbeat(watch.heartbeat_url, "start")
142
+ ```
143
+
144
+ Use `send_heartbeat` for `ping`, `start`, `success`, or `fail`; it always sends
145
+ POST. `signal_method="post"` prevents link previewers and security scanners
146
+ from accidentally recording a heartbeat with GET. The
147
+ source-scoped resource also exposes `client.watches.pause(id)`,
148
+ `resume(id)`, `rotate_token(id)`, and `archive(id)`; only create/rotate return
149
+ a raw URL. Store capability URLs in a secret manager; Watch details and
150
+ exports never return them.
151
+
152
+ ## License
153
+
154
+ MIT. See [LICENSE](./LICENSE).