actionbox 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.
@@ -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,131 @@
1
+ Metadata-Version: 2.4
2
+ Name: actionbox
3
+ Version: 0.1.2
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
+ Project-URL: Source, https://github.com/susonsapkota/actionbox
9
+ Requires-Python: >=3.11
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: httpx>=0.27
13
+ Dynamic: license-file
14
+
15
+ <img src="https://actionbox.cloud/appbox.svg" width="64" alt="Actionbox logo">
16
+
17
+ # Actionbox Python SDK
18
+
19
+ Actionbox gives backend services a durable, server-authoritative way to ask a
20
+ human for a decision and continue when that decision is available. This package
21
+ is the typed Python client for creating, resolving, and waiting on Actions,
22
+ plus managing source-scoped heartbeat Watches.
23
+
24
+ ## Documentation
25
+
26
+ - [Actionbox documentation](https://actionbox.cloud/docs)
27
+
28
+ ## Requirements
29
+
30
+ - Python 3.11 or newer
31
+ - An Actionbox Source API key, supplied through `ACTIONBOX_API_KEY`
32
+
33
+ Keep API keys and Watch capability URLs on trusted servers, workers, or CI
34
+ jobs. Do not put this SDK or its credentials in browser code.
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ pip install actionbox
40
+ ```
41
+
42
+ ```python
43
+ import os
44
+ from actionbox import Actionbox
45
+
46
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
47
+ decision = client.ask(
48
+ title="Deploy to production?",
49
+ options=["Approve", "Reject"],
50
+ callback_url="https://ci.example.com/actionbox",
51
+ )
52
+ print(decision)
53
+ ```
54
+
55
+ The SDK uses the hosted production API at `https://api.actionbox.cloud` by
56
+ default. Customer integrations should use that default and only pass
57
+ `base_url` in maintainer-controlled test environments.
58
+
59
+ `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.
60
+
61
+ ## Typed interactions and responses
62
+
63
+ 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:
64
+
65
+ ```python
66
+ from actionbox import Actionbox, BooleanInteraction
67
+
68
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
69
+ action = client.create(
70
+ title="Deploy configuration",
71
+ interaction=BooleanInteraction(
72
+ type="boolean",
73
+ label="Deploy now?",
74
+ true_label="Deploy",
75
+ false_label="Hold",
76
+ ),
77
+ )
78
+ resolved = client.resolve(
79
+ action.id,
80
+ response={"type": "boolean", "value": True},
81
+ reason="Approved by release manager",
82
+ )
83
+ print(resolved.response) # {"type": "boolean", "value": True}
84
+ ```
85
+
86
+ 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.
87
+
88
+ `resolve` supports concise single-choice syntax and generic typed input:
89
+
90
+ ```python
91
+ client.resolve(action.id, "approve") # single-choice shorthand
92
+ client.resolve(action.id, {"response": {"type": "text", "value": "ship"}})
93
+ client.actions.resolve(action.id, response={"type": "number", "value": 4.5})
94
+ ```
95
+
96
+ `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.
97
+
98
+ ## Heartbeat Watches
99
+
100
+ Source credentials can create and list Watches scoped to that Source. The raw heartbeat URL is returned only by creation:
101
+
102
+ ```python
103
+ from actionbox import Actionbox, send_heartbeat
104
+
105
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
106
+ watch = client.watches.create(
107
+ source_id="src_…",
108
+ name="Nightly backup",
109
+ schedule_type="interval",
110
+ interval_seconds=3600,
111
+ grace_seconds=60,
112
+ )
113
+ send_heartbeat(watch.heartbeat_url, "start")
114
+ ```
115
+
116
+ Use `send_heartbeat` for `ping`, `start`, `success`, or `fail`. The
117
+ source-scoped resource also exposes `client.watches.pause(id)`,
118
+ `resume(id)`, `rotate_token(id)`, and `archive(id)`; only create/rotate return
119
+ a raw URL. Store capability URLs in a secret manager; Watch details and
120
+ exports never return them.
121
+
122
+ ## Release and versioning
123
+
124
+ The Node and Python SDKs are released together from signed `sdk-vMAJOR.MINOR.PATCH`
125
+ tags. The release workflow derives the package versions from the tag, runs both
126
+ test suites, and publishes the packages only after the tag and publishing
127
+ environments pass their checks.
128
+
129
+ ## License
130
+
131
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,117 @@
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
26
+ ```
27
+
28
+ ```python
29
+ import os
30
+ from actionbox import Actionbox
31
+
32
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
33
+ decision = client.ask(
34
+ title="Deploy to production?",
35
+ options=["Approve", "Reject"],
36
+ callback_url="https://ci.example.com/actionbox",
37
+ )
38
+ print(decision)
39
+ ```
40
+
41
+ The SDK uses the hosted production API at `https://api.actionbox.cloud` by
42
+ default. Customer integrations should use that default and only pass
43
+ `base_url` in maintainer-controlled test environments.
44
+
45
+ `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.
46
+
47
+ ## Typed interactions and responses
48
+
49
+ 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:
50
+
51
+ ```python
52
+ from actionbox import Actionbox, BooleanInteraction
53
+
54
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
55
+ action = client.create(
56
+ title="Deploy configuration",
57
+ interaction=BooleanInteraction(
58
+ type="boolean",
59
+ label="Deploy now?",
60
+ true_label="Deploy",
61
+ false_label="Hold",
62
+ ),
63
+ )
64
+ resolved = client.resolve(
65
+ action.id,
66
+ response={"type": "boolean", "value": True},
67
+ reason="Approved by release manager",
68
+ )
69
+ print(resolved.response) # {"type": "boolean", "value": True}
70
+ ```
71
+
72
+ 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.
73
+
74
+ `resolve` supports concise single-choice syntax and generic typed input:
75
+
76
+ ```python
77
+ client.resolve(action.id, "approve") # single-choice shorthand
78
+ client.resolve(action.id, {"response": {"type": "text", "value": "ship"}})
79
+ client.actions.resolve(action.id, response={"type": "number", "value": 4.5})
80
+ ```
81
+
82
+ `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.
83
+
84
+ ## Heartbeat Watches
85
+
86
+ Source credentials can create and list Watches scoped to that Source. The raw heartbeat URL is returned only by creation:
87
+
88
+ ```python
89
+ from actionbox import Actionbox, send_heartbeat
90
+
91
+ with Actionbox(os.environ["ACTIONBOX_API_KEY"]) as client:
92
+ watch = client.watches.create(
93
+ source_id="src_…",
94
+ name="Nightly backup",
95
+ schedule_type="interval",
96
+ interval_seconds=3600,
97
+ grace_seconds=60,
98
+ )
99
+ send_heartbeat(watch.heartbeat_url, "start")
100
+ ```
101
+
102
+ Use `send_heartbeat` for `ping`, `start`, `success`, or `fail`. The
103
+ source-scoped resource also exposes `client.watches.pause(id)`,
104
+ `resume(id)`, `rotate_token(id)`, and `archive(id)`; only create/rotate return
105
+ a raw URL. Store capability URLs in a secret manager; Watch details and
106
+ exports never return them.
107
+
108
+ ## Release and versioning
109
+
110
+ The Node and Python SDKs are released together from signed `sdk-vMAJOR.MINOR.PATCH`
111
+ tags. The release workflow derives the package versions from the tag, runs both
112
+ test suites, and publishes the packages only after the tag and publishing
113
+ environments pass their checks.
114
+
115
+ ## License
116
+
117
+ MIT. See [LICENSE](./LICENSE).