cambium-client 0.1.0__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,23 @@
1
+ node_modules/
2
+ runs/
3
+ .DS_Store
4
+
5
+ # Build output
6
+ packages/*/dist/
7
+ *.tgz
8
+
9
+ # Secrets
10
+ .env
11
+
12
+ # Ruby
13
+ *.gem
14
+ .bundle/
15
+
16
+ # Python (cambium-client-python, RED-361)
17
+ __pycache__/
18
+ *.py[cod]
19
+ *$py.class
20
+ *.egg-info/
21
+ .venv/
22
+ .pytest_cache/
23
+ .mypy_cache/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Redwood Labs
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,247 @@
1
+ Metadata-Version: 2.4
2
+ Name: cambium-client
3
+ Version: 0.1.0
4
+ Summary: Python client for Cambium serve mode (RED-360). Speaks the v1 wire format over HTTP.
5
+ Project-URL: Homepage, https://redwoodlabs.ai
6
+ Project-URL: Repository, https://github.com/redwood-labs-ai/cambium
7
+ Project-URL: Issues, https://github.com/redwood-labs-ai/cambium/issues
8
+ Project-URL: Documentation, https://github.com/redwood-labs-ai/cambium/blob/main/docs/GenDSL%20Docs/C%20-%20Serve%20Mode.md
9
+ Author-email: Stephen Keider <hello@redwoodlabs.ai>
10
+ License: MIT License
11
+
12
+ Copyright (c) 2026 Redwood Labs
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ Keywords: agent,ai,cambium,client,fastapi,http,llm
33
+ Classifier: Development Status :: 4 - Beta
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Classifier: Programming Language :: Python :: 3.12
41
+ Classifier: Programming Language :: Python :: 3.13
42
+ Classifier: Topic :: Software Development :: Libraries
43
+ Classifier: Typing :: Typed
44
+ Requires-Python: >=3.10
45
+ Requires-Dist: httpx<1.0,>=0.27.2
46
+ Provides-Extra: dev
47
+ Requires-Dist: build>=1.2; extra == 'dev'
48
+ Requires-Dist: mypy>=1.10; extra == 'dev'
49
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
50
+ Requires-Dist: pytest>=8.0; extra == 'dev'
51
+ Requires-Dist: twine>=5.0; extra == 'dev'
52
+ Description-Content-Type: text/markdown
53
+
54
+ # cambium-client
55
+
56
+ Python client for [Cambium](https://github.com/redwood-labs-ai/cambium) serve mode (RED-360). Speaks the v1 HTTP wire format — `pip install cambium-client`, point at a running `cambium serve` process, call gens.
57
+
58
+ The transport for non-Node hosts (FastAPI, Django, Flask, Go via HTTP, Elixir, anything that needs warm Cambium without a Node bridge). One `httpx`-backed `CambiumClient` exposes both sync and async paths from the same connection pool.
59
+
60
+ ## Install
61
+
62
+ ```bash
63
+ pip install cambium-client
64
+ ```
65
+
66
+ Requires Python 3.10+. Single runtime dependency: `httpx>=0.27.2`.
67
+
68
+ ## Quickstart
69
+
70
+ Run `cambium serve` somewhere reachable (loopback for the same-host case; Docker network for sidecar):
71
+
72
+ ```bash
73
+ cambium serve --workspace ./cambium --bind tcp://127.0.0.1:9000
74
+ ```
75
+
76
+ Then from Python:
77
+
78
+ ```python
79
+ from cambium_client import CambiumClient
80
+
81
+ # Sync
82
+ with CambiumClient(url="http://127.0.0.1:9000") as client:
83
+ output = client.run("ResumeParser", "analyze", resume_text)
84
+ # → whatever the gen's `returns` schema produced
85
+
86
+ # Async
87
+ async with CambiumClient(url="http://127.0.0.1:9000") as client:
88
+ output = await client.run_async("ResumeParser", "analyze", resume_text)
89
+ ```
90
+
91
+ `client.run()` returns the bare `output` dict on success. Failures raise a typed `CambiumError` subclass — see [Errors](#errors) below.
92
+
93
+ ## Transports
94
+
95
+ | Scheme | v1 support | Notes |
96
+ | -- | -- | -- |
97
+ | `http://host:port` / `https://...` | ✅ | Standard `httpx` HTTP transport. |
98
+ | `tcp://host:port` | ✅ | Convenience form (matches `cambium serve --bind`); rewritten to `http://`. |
99
+ | `unix:///abs/path` | ✅ | UDS via `httpx.HTTPTransport(uds=...)`. Mac / Linux. |
100
+ | `pipe://name` | ❌ (v1.1) | Windows named pipes — raises `NotImplementedError` until v1.1. Use `tcp://127.0.0.1:<port>` on Windows in v1. |
101
+
102
+ ## API
103
+
104
+ ### `CambiumClient(url, *, timeout=30.0, headers=None, probe=False)`
105
+
106
+ | Argument | Type | Default | Notes |
107
+ | -- | -- | -- | -- |
108
+ | `url` | `str` | (required) | Server URL. See [Transports](#transports). |
109
+ | `timeout` | `float` | `30.0` | Per-request timeout in seconds. |
110
+ | `headers` | `Mapping[str, str]` | `None` | Extra HTTP headers (e.g. tracing). |
111
+ | `probe` | `bool` | `False` | If `True`, call `/v1/healthz` from the constructor and raise `CambiumConnectionError` if the server isn't reachable (or `BootingError` if it's still loading gens). |
112
+
113
+ ### `client.run(gen, method, input, *, memory_keys=None, fired_by=None, include_trace=False)`
114
+
115
+ Dispatch a gen run. Returns the bare `output` from the response on success; raises a `CambiumError` subclass on failure.
116
+
117
+ | Argument | Type | Notes |
118
+ | -- | -- | -- |
119
+ | `gen` | `str` | Gen export name from the server's `Genfile.toml [exports.gens]`. |
120
+ | `method` | `str` | Public method on the GenModel (typically `analyze`). |
121
+ | `input` | `str \| dict \| list \| bytes` | Bytes are decoded UTF-8 (JSON can't carry raw bytes). Dicts/lists pass through unchanged; the server stringifies non-string `input` values into `ir.context.<source>`. |
122
+ | `memory_keys` | `Mapping[str, str]` | Values for `keyed_by` memory slots. Forwarded to the server as a dict. |
123
+ | `fired_by` | `str` | Schedule id for `cron`-fired runs (e.g. `"schedule:daily.x"`). |
124
+ | `include_trace` | `bool` | If `True`, the server returns the trace inline. The current `run()` API still returns just the output; trace surfacing in the response is a follow-up (`run_envelope()`). |
125
+
126
+ ### `client.healthz()`
127
+
128
+ Probe `/v1/healthz`. Returns a `Healthz` dataclass (`status`, `gens`, `version`). Raises `BootingError` while the server is still pre-compiling gens, `CambiumConnectionError` if it can't be reached.
129
+
130
+ ### Async parity
131
+
132
+ `client.run_async(...)` and `client.healthz_async()` mirror their sync siblings with identical signatures and exception trees. Use either path on the same `CambiumClient` instance — both pools live independently. `async with` cleans up both.
133
+
134
+ ### Context manager
135
+
136
+ ```python
137
+ # Sync
138
+ with CambiumClient(url=...) as client:
139
+ ...
140
+
141
+ # Async
142
+ async with CambiumClient(url=...) as client:
143
+ ...
144
+ ```
145
+
146
+ Outside a context manager, call `client.close()` (sync) or `await client.aclose()` (async) explicitly.
147
+
148
+ ## Errors
149
+
150
+ Every server failure surfaces as a `CambiumError` subclass keyed off the wire `error.kind` enum. Catch by subclass for fine-grained handling, or `CambiumError` as the umbrella:
151
+
152
+ | `error.kind` | Exception | When |
153
+ | -- | -- | -- |
154
+ | `unknown_gen` | `UnknownGenError` | Gen name not in catalog. |
155
+ | `unknown_method` | `UnknownMethodError` | Gen exists, method does not. |
156
+ | `input_invalid` | `InputInvalidError` | Malformed body, missing required fields, oversize. |
157
+ | `validation_failed` | `ValidationFailedError` | Schema validation exhausted after repair attempts. |
158
+ | `budget_exhausted` | `BudgetExhaustedError` | `BudgetExceededError` inside `runGen`. |
159
+ | `tool_dispatch_failed` | `ToolDispatchFailedError` | Unknown tool, action, or security violation. |
160
+ | `runner_error` | `RunnerError` (alias: `CambiumRunError`) | Other runtime failures. |
161
+ | `timeout` | `CambiumTimeoutError` | `--run-timeout` deadline missed. |
162
+ | `overloaded` | `OverloadedError` | `--max-inflight` cap hit; backoff and retry. |
163
+ | `booting` | `BootingError` | Server still pre-compiling at boot. |
164
+ | `not_found` | `NotFoundError` | Unknown HTTP route. |
165
+ | *(transport)* | `CambiumConnectionError` (alias: `CambiumNotFoundError`) | Server unreachable. |
166
+
167
+ Every exception carries `.kind: str`, `.run_id: str | None` (null on pre-dispatch errors), and `.details: dict | None`. Future server kinds we don't know about surface via the `CambiumError` base class with the real `.kind` populated rather than the request silently "succeeding."
168
+
169
+ ```python
170
+ from cambium_client import (
171
+ CambiumClient, BudgetExhaustedError, CambiumTimeoutError, OverloadedError,
172
+ )
173
+
174
+ with CambiumClient(url=...) as client:
175
+ try:
176
+ result = client.run("ResumeParser", "analyze", resume_text)
177
+ except OverloadedError:
178
+ # Back off + retry
179
+ ...
180
+ except (BudgetExhaustedError, CambiumTimeoutError) as e:
181
+ # Surface to caller; e.run_id can be correlated with the on-disk trace
182
+ log.warning("cambium failure: kind=%s run_id=%s", e.kind, e.run_id)
183
+ raise
184
+ ```
185
+
186
+ ## Subprocess fallback (recipe)
187
+
188
+ `cambium-client` is pure HTTP — it does NOT bake in a subprocess fallback for `CAMBIUM_SERVE_URL` unset. Callers who want graceful degradation when the server isn't available can wire it themselves in ~5 lines:
189
+
190
+ ```python
191
+ import os
192
+ from cambium_client import CambiumClient, CambiumConnectionError
193
+
194
+ def run_gen(gen: str, method: str, input_data):
195
+ url = os.environ.get("CAMBIUM_SERVE_URL")
196
+ if url:
197
+ with CambiumClient(url=url) as c:
198
+ return c.run(gen, method, input_data)
199
+ # Fallback: shell out to `cambium run` (your existing wrapper),
200
+ # or raise a clear "server not configured" error.
201
+ raise RuntimeError("CAMBIUM_SERVE_URL is unset and no fallback configured")
202
+ ```
203
+
204
+ ## Migration from a subprocess wrapper
205
+
206
+ If you already have a `services/cambium.py` that wraps `subprocess.run(["cambium", "run", ...])` with `CambiumError` / `CambiumRunError` / `CambiumNotFoundError`, this client keeps those names compatible. Replace the subprocess `run()` body with a `CambiumClient(...).run()` call; the exception names propagate.
207
+
208
+ ## Versioning
209
+
210
+ Wire-format pinning: `cambium-client` targets the server's `/v1/` routes. The constant `cambium_client.WIRE_VERSION` is `"v1"`. A future server `/v2/` is a separate client release (`cambium-client-v2`-style or major bump).
211
+
212
+ Adheres to [SemVer](https://semver.org/). The `error.kind` enum is closed in v1 — new kinds are a v2 break.
213
+
214
+ ## Publishing (maintainer)
215
+
216
+ Manual flow, mirroring the runner package's npm flow:
217
+
218
+ ```bash
219
+ cd packages/cambium-client-python
220
+
221
+ # 1. Bump src/cambium_client/_version.py.
222
+ # 2. Build the wheel.
223
+ python -m build
224
+
225
+ # 3. Gate: pre-publish-check builds in a fresh venv + smoke-imports
226
+ # + asserts py.typed ships + asserts no stray tests/ in the wheel.
227
+ python scripts/pre_publish_check.py
228
+
229
+ # 4. Final check via twine.
230
+ python -m twine check dist/*
231
+
232
+ # 5. Smoke-test from TestPyPI first.
233
+ python -m twine upload --repository testpypi dist/*
234
+
235
+ # 6. Real PyPI.
236
+ python -m twine upload dist/*
237
+
238
+ # 7. Tag.
239
+ git tag cambium-client@v0.1.0
240
+ git push --tags
241
+ ```
242
+
243
+ The `pre_publish_check.py` script is the analogue of the runner package's `scripts/pre-publish-check.mjs`: it validates the published *artifact* by building the wheel, installing it into a fresh venv (not the source tree), smoke-importing, and inspecting the wheel zip for stray test/cache files. Any failure exits non-zero.
244
+
245
+ ## License
246
+
247
+ MIT. See `LICENSE`.
@@ -0,0 +1,194 @@
1
+ # cambium-client
2
+
3
+ Python client for [Cambium](https://github.com/redwood-labs-ai/cambium) serve mode (RED-360). Speaks the v1 HTTP wire format — `pip install cambium-client`, point at a running `cambium serve` process, call gens.
4
+
5
+ The transport for non-Node hosts (FastAPI, Django, Flask, Go via HTTP, Elixir, anything that needs warm Cambium without a Node bridge). One `httpx`-backed `CambiumClient` exposes both sync and async paths from the same connection pool.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install cambium-client
11
+ ```
12
+
13
+ Requires Python 3.10+. Single runtime dependency: `httpx>=0.27.2`.
14
+
15
+ ## Quickstart
16
+
17
+ Run `cambium serve` somewhere reachable (loopback for the same-host case; Docker network for sidecar):
18
+
19
+ ```bash
20
+ cambium serve --workspace ./cambium --bind tcp://127.0.0.1:9000
21
+ ```
22
+
23
+ Then from Python:
24
+
25
+ ```python
26
+ from cambium_client import CambiumClient
27
+
28
+ # Sync
29
+ with CambiumClient(url="http://127.0.0.1:9000") as client:
30
+ output = client.run("ResumeParser", "analyze", resume_text)
31
+ # → whatever the gen's `returns` schema produced
32
+
33
+ # Async
34
+ async with CambiumClient(url="http://127.0.0.1:9000") as client:
35
+ output = await client.run_async("ResumeParser", "analyze", resume_text)
36
+ ```
37
+
38
+ `client.run()` returns the bare `output` dict on success. Failures raise a typed `CambiumError` subclass — see [Errors](#errors) below.
39
+
40
+ ## Transports
41
+
42
+ | Scheme | v1 support | Notes |
43
+ | -- | -- | -- |
44
+ | `http://host:port` / `https://...` | ✅ | Standard `httpx` HTTP transport. |
45
+ | `tcp://host:port` | ✅ | Convenience form (matches `cambium serve --bind`); rewritten to `http://`. |
46
+ | `unix:///abs/path` | ✅ | UDS via `httpx.HTTPTransport(uds=...)`. Mac / Linux. |
47
+ | `pipe://name` | ❌ (v1.1) | Windows named pipes — raises `NotImplementedError` until v1.1. Use `tcp://127.0.0.1:<port>` on Windows in v1. |
48
+
49
+ ## API
50
+
51
+ ### `CambiumClient(url, *, timeout=30.0, headers=None, probe=False)`
52
+
53
+ | Argument | Type | Default | Notes |
54
+ | -- | -- | -- | -- |
55
+ | `url` | `str` | (required) | Server URL. See [Transports](#transports). |
56
+ | `timeout` | `float` | `30.0` | Per-request timeout in seconds. |
57
+ | `headers` | `Mapping[str, str]` | `None` | Extra HTTP headers (e.g. tracing). |
58
+ | `probe` | `bool` | `False` | If `True`, call `/v1/healthz` from the constructor and raise `CambiumConnectionError` if the server isn't reachable (or `BootingError` if it's still loading gens). |
59
+
60
+ ### `client.run(gen, method, input, *, memory_keys=None, fired_by=None, include_trace=False)`
61
+
62
+ Dispatch a gen run. Returns the bare `output` from the response on success; raises a `CambiumError` subclass on failure.
63
+
64
+ | Argument | Type | Notes |
65
+ | -- | -- | -- |
66
+ | `gen` | `str` | Gen export name from the server's `Genfile.toml [exports.gens]`. |
67
+ | `method` | `str` | Public method on the GenModel (typically `analyze`). |
68
+ | `input` | `str \| dict \| list \| bytes` | Bytes are decoded UTF-8 (JSON can't carry raw bytes). Dicts/lists pass through unchanged; the server stringifies non-string `input` values into `ir.context.<source>`. |
69
+ | `memory_keys` | `Mapping[str, str]` | Values for `keyed_by` memory slots. Forwarded to the server as a dict. |
70
+ | `fired_by` | `str` | Schedule id for `cron`-fired runs (e.g. `"schedule:daily.x"`). |
71
+ | `include_trace` | `bool` | If `True`, the server returns the trace inline. The current `run()` API still returns just the output; trace surfacing in the response is a follow-up (`run_envelope()`). |
72
+
73
+ ### `client.healthz()`
74
+
75
+ Probe `/v1/healthz`. Returns a `Healthz` dataclass (`status`, `gens`, `version`). Raises `BootingError` while the server is still pre-compiling gens, `CambiumConnectionError` if it can't be reached.
76
+
77
+ ### Async parity
78
+
79
+ `client.run_async(...)` and `client.healthz_async()` mirror their sync siblings with identical signatures and exception trees. Use either path on the same `CambiumClient` instance — both pools live independently. `async with` cleans up both.
80
+
81
+ ### Context manager
82
+
83
+ ```python
84
+ # Sync
85
+ with CambiumClient(url=...) as client:
86
+ ...
87
+
88
+ # Async
89
+ async with CambiumClient(url=...) as client:
90
+ ...
91
+ ```
92
+
93
+ Outside a context manager, call `client.close()` (sync) or `await client.aclose()` (async) explicitly.
94
+
95
+ ## Errors
96
+
97
+ Every server failure surfaces as a `CambiumError` subclass keyed off the wire `error.kind` enum. Catch by subclass for fine-grained handling, or `CambiumError` as the umbrella:
98
+
99
+ | `error.kind` | Exception | When |
100
+ | -- | -- | -- |
101
+ | `unknown_gen` | `UnknownGenError` | Gen name not in catalog. |
102
+ | `unknown_method` | `UnknownMethodError` | Gen exists, method does not. |
103
+ | `input_invalid` | `InputInvalidError` | Malformed body, missing required fields, oversize. |
104
+ | `validation_failed` | `ValidationFailedError` | Schema validation exhausted after repair attempts. |
105
+ | `budget_exhausted` | `BudgetExhaustedError` | `BudgetExceededError` inside `runGen`. |
106
+ | `tool_dispatch_failed` | `ToolDispatchFailedError` | Unknown tool, action, or security violation. |
107
+ | `runner_error` | `RunnerError` (alias: `CambiumRunError`) | Other runtime failures. |
108
+ | `timeout` | `CambiumTimeoutError` | `--run-timeout` deadline missed. |
109
+ | `overloaded` | `OverloadedError` | `--max-inflight` cap hit; backoff and retry. |
110
+ | `booting` | `BootingError` | Server still pre-compiling at boot. |
111
+ | `not_found` | `NotFoundError` | Unknown HTTP route. |
112
+ | *(transport)* | `CambiumConnectionError` (alias: `CambiumNotFoundError`) | Server unreachable. |
113
+
114
+ Every exception carries `.kind: str`, `.run_id: str | None` (null on pre-dispatch errors), and `.details: dict | None`. Future server kinds we don't know about surface via the `CambiumError` base class with the real `.kind` populated rather than the request silently "succeeding."
115
+
116
+ ```python
117
+ from cambium_client import (
118
+ CambiumClient, BudgetExhaustedError, CambiumTimeoutError, OverloadedError,
119
+ )
120
+
121
+ with CambiumClient(url=...) as client:
122
+ try:
123
+ result = client.run("ResumeParser", "analyze", resume_text)
124
+ except OverloadedError:
125
+ # Back off + retry
126
+ ...
127
+ except (BudgetExhaustedError, CambiumTimeoutError) as e:
128
+ # Surface to caller; e.run_id can be correlated with the on-disk trace
129
+ log.warning("cambium failure: kind=%s run_id=%s", e.kind, e.run_id)
130
+ raise
131
+ ```
132
+
133
+ ## Subprocess fallback (recipe)
134
+
135
+ `cambium-client` is pure HTTP — it does NOT bake in a subprocess fallback for `CAMBIUM_SERVE_URL` unset. Callers who want graceful degradation when the server isn't available can wire it themselves in ~5 lines:
136
+
137
+ ```python
138
+ import os
139
+ from cambium_client import CambiumClient, CambiumConnectionError
140
+
141
+ def run_gen(gen: str, method: str, input_data):
142
+ url = os.environ.get("CAMBIUM_SERVE_URL")
143
+ if url:
144
+ with CambiumClient(url=url) as c:
145
+ return c.run(gen, method, input_data)
146
+ # Fallback: shell out to `cambium run` (your existing wrapper),
147
+ # or raise a clear "server not configured" error.
148
+ raise RuntimeError("CAMBIUM_SERVE_URL is unset and no fallback configured")
149
+ ```
150
+
151
+ ## Migration from a subprocess wrapper
152
+
153
+ If you already have a `services/cambium.py` that wraps `subprocess.run(["cambium", "run", ...])` with `CambiumError` / `CambiumRunError` / `CambiumNotFoundError`, this client keeps those names compatible. Replace the subprocess `run()` body with a `CambiumClient(...).run()` call; the exception names propagate.
154
+
155
+ ## Versioning
156
+
157
+ Wire-format pinning: `cambium-client` targets the server's `/v1/` routes. The constant `cambium_client.WIRE_VERSION` is `"v1"`. A future server `/v2/` is a separate client release (`cambium-client-v2`-style or major bump).
158
+
159
+ Adheres to [SemVer](https://semver.org/). The `error.kind` enum is closed in v1 — new kinds are a v2 break.
160
+
161
+ ## Publishing (maintainer)
162
+
163
+ Manual flow, mirroring the runner package's npm flow:
164
+
165
+ ```bash
166
+ cd packages/cambium-client-python
167
+
168
+ # 1. Bump src/cambium_client/_version.py.
169
+ # 2. Build the wheel.
170
+ python -m build
171
+
172
+ # 3. Gate: pre-publish-check builds in a fresh venv + smoke-imports
173
+ # + asserts py.typed ships + asserts no stray tests/ in the wheel.
174
+ python scripts/pre_publish_check.py
175
+
176
+ # 4. Final check via twine.
177
+ python -m twine check dist/*
178
+
179
+ # 5. Smoke-test from TestPyPI first.
180
+ python -m twine upload --repository testpypi dist/*
181
+
182
+ # 6. Real PyPI.
183
+ python -m twine upload dist/*
184
+
185
+ # 7. Tag.
186
+ git tag cambium-client@v0.1.0
187
+ git push --tags
188
+ ```
189
+
190
+ The `pre_publish_check.py` script is the analogue of the runner package's `scripts/pre-publish-check.mjs`: it validates the published *artifact* by building the wheel, installing it into a fresh venv (not the source tree), smoke-importing, and inspecting the wheel zip for stray test/cache files. Any failure exits non-zero.
191
+
192
+ ## License
193
+
194
+ MIT. See `LICENSE`.
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "cambium-client"
7
+ description = "Python client for Cambium serve mode (RED-360). Speaks the v1 wire format over HTTP."
8
+ readme = "README.md"
9
+ license = { file = "LICENSE" }
10
+ authors = [
11
+ { name = "Stephen Keider", email = "hello@redwoodlabs.ai" },
12
+ ]
13
+ keywords = [
14
+ "llm",
15
+ "ai",
16
+ "agent",
17
+ "cambium",
18
+ "client",
19
+ "http",
20
+ "fastapi",
21
+ ]
22
+ classifiers = [
23
+ "Development Status :: 4 - Beta",
24
+ "Intended Audience :: Developers",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Operating System :: OS Independent",
27
+ "Programming Language :: Python :: 3",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Topic :: Software Development :: Libraries",
33
+ "Typing :: Typed",
34
+ ]
35
+ requires-python = ">=3.10"
36
+ dynamic = ["version"]
37
+ # httpx 0.27.0 had a UDS-async regression fixed in 0.27.2 — pin the floor
38
+ # above it. Upper bound is conservative for httpx's still-pre-1.0 surface;
39
+ # revisit when 1.0 lands or when a 0.28 release is needed.
40
+ dependencies = [
41
+ "httpx>=0.27.2,<1.0",
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://redwoodlabs.ai"
46
+ Repository = "https://github.com/redwood-labs-ai/cambium"
47
+ Issues = "https://github.com/redwood-labs-ai/cambium/issues"
48
+ Documentation = "https://github.com/redwood-labs-ai/cambium/blob/main/docs/GenDSL%20Docs/C%20-%20Serve%20Mode.md"
49
+
50
+ [project.optional-dependencies]
51
+ dev = [
52
+ "pytest>=8.0",
53
+ "pytest-asyncio>=0.24",
54
+ "mypy>=1.10",
55
+ "build>=1.2",
56
+ "twine>=5.0",
57
+ ]
58
+
59
+ [tool.hatch.version]
60
+ path = "src/cambium_client/_version.py"
61
+
62
+ [tool.hatch.build.targets.wheel]
63
+ packages = ["src/cambium_client"]
64
+
65
+ [tool.pytest.ini_options]
66
+ asyncio_mode = "auto"
67
+ testpaths = ["tests"]
68
+
69
+ [tool.mypy]
70
+ python_version = "3.10"
71
+ strict = true