k9o 1.0.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.
Files changed (52) hide show
  1. k9o-1.0.0/LICENSE +201 -0
  2. k9o-1.0.0/NOTICE +4 -0
  3. k9o-1.0.0/PKG-INFO +96 -0
  4. k9o-1.0.0/README.md +75 -0
  5. k9o-1.0.0/k9o/__init__.py +143 -0
  6. k9o-1.0.0/k9o/ai.py +45 -0
  7. k9o-1.0.0/k9o/audit.py +48 -0
  8. k9o-1.0.0/k9o/barbican/__init__.py +20 -0
  9. k9o-1.0.0/k9o/barbican/_ffi/__init__.py +5 -0
  10. k9o-1.0.0/k9o/barbican/barbican.py +218 -0
  11. k9o-1.0.0/k9o/client.py +132 -0
  12. k9o-1.0.0/k9o/compute.py +94 -0
  13. k9o-1.0.0/k9o/data.py +246 -0
  14. k9o-1.0.0/k9o/envelope.py +144 -0
  15. k9o-1.0.0/k9o/errors.py +87 -0
  16. k9o-1.0.0/k9o/functions.py +58 -0
  17. k9o-1.0.0/k9o/gate.py +100 -0
  18. k9o-1.0.0/k9o/http.py +378 -0
  19. k9o-1.0.0/k9o/kibo/__init__.py +53 -0
  20. k9o-1.0.0/k9o/kibo/_ffi/__init__.py +3 -0
  21. k9o-1.0.0/k9o/kibo/crypto.py +62 -0
  22. k9o-1.0.0/k9o/kibo_vault.py +285 -0
  23. k9o-1.0.0/k9o/me.py +109 -0
  24. k9o-1.0.0/k9o/migrations.py +355 -0
  25. k9o-1.0.0/k9o/org.py +180 -0
  26. k9o-1.0.0/k9o/orgs.py +35 -0
  27. k9o-1.0.0/k9o/policies.py +70 -0
  28. k9o-1.0.0/k9o/projects.py +67 -0
  29. k9o-1.0.0/k9o/realtime.py +150 -0
  30. k9o-1.0.0/k9o/region.py +110 -0
  31. k9o-1.0.0/k9o/storage.py +334 -0
  32. k9o-1.0.0/k9o/studio.py +197 -0
  33. k9o-1.0.0/k9o/url_grammar.py +119 -0
  34. k9o-1.0.0/k9o.egg-info/PKG-INFO +96 -0
  35. k9o-1.0.0/k9o.egg-info/SOURCES.txt +50 -0
  36. k9o-1.0.0/k9o.egg-info/dependency_links.txt +1 -0
  37. k9o-1.0.0/k9o.egg-info/requires.txt +9 -0
  38. k9o-1.0.0/k9o.egg-info/top_level.txt +1 -0
  39. k9o-1.0.0/pyproject.toml +53 -0
  40. k9o-1.0.0/setup.cfg +4 -0
  41. k9o-1.0.0/tests/test_ai_embed.py +68 -0
  42. k9o-1.0.0/tests/test_barbican.py +195 -0
  43. k9o-1.0.0/tests/test_client.py +369 -0
  44. k9o-1.0.0/tests/test_errors.py +63 -0
  45. k9o-1.0.0/tests/test_kibo_crypto.py +50 -0
  46. k9o-1.0.0/tests/test_p6.py +189 -0
  47. k9o-1.0.0/tests/test_parity.py +161 -0
  48. k9o-1.0.0/tests/test_region.py +213 -0
  49. k9o-1.0.0/tests/test_retry.py +88 -0
  50. k9o-1.0.0/tests/test_storage.py +359 -0
  51. k9o-1.0.0/tests/test_url_grammar.py +139 -0
  52. k9o-1.0.0/tests/test_vault_secrets.py +204 -0
k9o-1.0.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
k9o-1.0.0/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Kilimanjaro SDK
2
+ Copyright 2026 Formelo Inc.
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
k9o-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.4
2
+ Name: k9o
3
+ Version: 1.0.0
4
+ Summary: Kilimanjaro platform SDK — createClient + data DSL + projects + gate + migrations + functions + policies + audit + orgs + me + org + studio (workflows/dashboards) + compute.llms + realtime subscriptions + kibo (ZK vault) + barbican (Keep L2 guardrail) + KError. Full TS-surface parity. Python idiomatic (snake_case; raise KError; async for streams).
5
+ Author-email: Kilimanjaro <engineering@kilimanjaro.dev>
6
+ License: Apache-2.0
7
+ Project-URL: homepage, https://kilimanjaro.dev
8
+ Project-URL: repository, https://github.com/k9o-dev/sdk-python
9
+ Keywords: kilimanjaro,k9o,sdk,platform
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Requires-Dist: httpx>=0.27.0
15
+ Requires-Dist: typing_extensions>=4.0; python_version < "3.11"
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest>=8.0; extra == "dev"
18
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
19
+ Requires-Dist: respx>=0.21; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ # k9o — Kilimanjaro platform SDK (Python)
23
+
24
+ Idiomatic Python SDK. Snake_case methods; raise `KError` on error; data DSL via `client.from_("collection").select()`; typed envelope with meta accessor sugar.
25
+
26
+ ## Status
27
+
28
+ v0.1.0 — first-pass idiomatic ship (P3 wave 1; reshape from prior `k9o_gate` OpenAPI codegen).
29
+
30
+ Surfaces shipped:
31
+
32
+ - `create_client(...)` factory + baseUrl validation per ch13 §7
33
+ - `KError(Exception)` with `kerror_from_wire` rehydration
34
+ - `Envelope` + typed `Meta` accessor (`MetaCursor` / `MetaSubscription` / `MetaIdempotency` / `MetaWarning` / `MetaTiming` / `MetaContext`) per ch01 §1 + ch13 §5
35
+ - URL grammar v2.5.68 (`validate_base_url` / `validate_slug` / `project_path` / `org_path` / `platform_path`)
36
+ - Data-plane DSL: `client.from_(collection)` with chainable filter builder (`.eq` / `.neq` / `.gt` / `.gte` / `.lt` / `.lte` / `.in_` / `.not_in` / `.like` / `.ilike` / `.is_` / `.filter`) + `.limit` / `.cursor` / `.count` + terminal verbs (`.select().execute()` / `.insert()` / `.update().eq("id", ...).execute()` / `.delete().eq("id", ...).execute()`)
37
+ - `client.projects.{list,create,get,update}`
38
+ - `client.ai.embed(input, model=None)` (platform embeddings; requires project_slug)
39
+ - `client.gate.{sign_up,sign_in,sign_out,whoami,refresh_token,verify_session,hosted}` (project-scoped auth)
40
+ - `client.storage.{create_bucket,get_bucket,list_buckets,update_bucket,delete_bucket}` and `client.storage.from_(bucket).{upload,create_signed_url,list,remove}` (buckets and objects; `_async` twins; requires project_slug; `expires_in` is required, 1..604800)
41
+ - Sync (`request`) + async (`request_async`) HTTP via httpx
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ pip install k9o
47
+ ```
48
+
49
+ (Pre-launch: install from monorepo source via `pip install -e packages/python`.)
50
+
51
+ ## Quick start
52
+
53
+ ```python
54
+ import os
55
+ from k9o import create_client, KError
56
+
57
+ k9o = create_client(
58
+ base_url="https://acme.api.k9o.io",
59
+ api_key=os.environ["K9O_API_KEY"],
60
+ org_slug="acme",
61
+ project_slug="member-portal",
62
+ )
63
+
64
+ try:
65
+ response = k9o.from_("posts").select().limit(10).execute()
66
+ for row in response.data:
67
+ print(row)
68
+ if response.meta.cursor:
69
+ print("next cursor:", response.meta.cursor.next)
70
+
71
+ session = k9o.gate.sign_in(email="user@example.com", password="…")
72
+ print("signed in:", session.data["user"]["id"])
73
+ except KError as e:
74
+ print(f"[{e.code}] {e.message}: {e.recommendation}")
75
+ raise
76
+ ```
77
+
78
+ ## Idiomatic shape (per ch13)
79
+
80
+ | Aspect | This SDK |
81
+ |---|---|
82
+ | Package name | `k9o` (PyPI) |
83
+ | Method casing | `snake_case` |
84
+ | Constants | `SCREAMING_SNAKE_CASE` |
85
+ | KError delivery | `raise KError` (catch with `except KError as e:`) |
86
+ | Data DSL entry | `client.from_("collection")` (`from` is a Python keyword; `from_` is the idiomatic mapping) |
87
+ | Filter chain | `.eq()` / `.gt()` / `.in_()` / `.is_()` (`_` suffix on Python reserved-keyword names) |
88
+ | Terminal verb | `.execute()` (explicit; async parallel `.execute_async()`) |
89
+ | Meta accessor | `response.meta.cursor.next`, `response.meta.timing.total_ms`, `response.meta.context.request_id` (snake_case attrs translated from camelCase wire) |
90
+ | Wire format | Always camelCase JSON (ch01 §3.3 invariant) — translated at boundary |
91
+ | Runtime | Python 3.10+ |
92
+ | HTTP library | httpx (sync + async; modern) |
93
+
94
+ ## License
95
+
96
+ UNLICENSED — internal to Kilimanjaro.
k9o-1.0.0/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # k9o — Kilimanjaro platform SDK (Python)
2
+
3
+ Idiomatic Python SDK. Snake_case methods; raise `KError` on error; data DSL via `client.from_("collection").select()`; typed envelope with meta accessor sugar.
4
+
5
+ ## Status
6
+
7
+ v0.1.0 — first-pass idiomatic ship (P3 wave 1; reshape from prior `k9o_gate` OpenAPI codegen).
8
+
9
+ Surfaces shipped:
10
+
11
+ - `create_client(...)` factory + baseUrl validation per ch13 §7
12
+ - `KError(Exception)` with `kerror_from_wire` rehydration
13
+ - `Envelope` + typed `Meta` accessor (`MetaCursor` / `MetaSubscription` / `MetaIdempotency` / `MetaWarning` / `MetaTiming` / `MetaContext`) per ch01 §1 + ch13 §5
14
+ - URL grammar v2.5.68 (`validate_base_url` / `validate_slug` / `project_path` / `org_path` / `platform_path`)
15
+ - Data-plane DSL: `client.from_(collection)` with chainable filter builder (`.eq` / `.neq` / `.gt` / `.gte` / `.lt` / `.lte` / `.in_` / `.not_in` / `.like` / `.ilike` / `.is_` / `.filter`) + `.limit` / `.cursor` / `.count` + terminal verbs (`.select().execute()` / `.insert()` / `.update().eq("id", ...).execute()` / `.delete().eq("id", ...).execute()`)
16
+ - `client.projects.{list,create,get,update}`
17
+ - `client.ai.embed(input, model=None)` (platform embeddings; requires project_slug)
18
+ - `client.gate.{sign_up,sign_in,sign_out,whoami,refresh_token,verify_session,hosted}` (project-scoped auth)
19
+ - `client.storage.{create_bucket,get_bucket,list_buckets,update_bucket,delete_bucket}` and `client.storage.from_(bucket).{upload,create_signed_url,list,remove}` (buckets and objects; `_async` twins; requires project_slug; `expires_in` is required, 1..604800)
20
+ - Sync (`request`) + async (`request_async`) HTTP via httpx
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install k9o
26
+ ```
27
+
28
+ (Pre-launch: install from monorepo source via `pip install -e packages/python`.)
29
+
30
+ ## Quick start
31
+
32
+ ```python
33
+ import os
34
+ from k9o import create_client, KError
35
+
36
+ k9o = create_client(
37
+ base_url="https://acme.api.k9o.io",
38
+ api_key=os.environ["K9O_API_KEY"],
39
+ org_slug="acme",
40
+ project_slug="member-portal",
41
+ )
42
+
43
+ try:
44
+ response = k9o.from_("posts").select().limit(10).execute()
45
+ for row in response.data:
46
+ print(row)
47
+ if response.meta.cursor:
48
+ print("next cursor:", response.meta.cursor.next)
49
+
50
+ session = k9o.gate.sign_in(email="user@example.com", password="…")
51
+ print("signed in:", session.data["user"]["id"])
52
+ except KError as e:
53
+ print(f"[{e.code}] {e.message}: {e.recommendation}")
54
+ raise
55
+ ```
56
+
57
+ ## Idiomatic shape (per ch13)
58
+
59
+ | Aspect | This SDK |
60
+ |---|---|
61
+ | Package name | `k9o` (PyPI) |
62
+ | Method casing | `snake_case` |
63
+ | Constants | `SCREAMING_SNAKE_CASE` |
64
+ | KError delivery | `raise KError` (catch with `except KError as e:`) |
65
+ | Data DSL entry | `client.from_("collection")` (`from` is a Python keyword; `from_` is the idiomatic mapping) |
66
+ | Filter chain | `.eq()` / `.gt()` / `.in_()` / `.is_()` (`_` suffix on Python reserved-keyword names) |
67
+ | Terminal verb | `.execute()` (explicit; async parallel `.execute_async()`) |
68
+ | Meta accessor | `response.meta.cursor.next`, `response.meta.timing.total_ms`, `response.meta.context.request_id` (snake_case attrs translated from camelCase wire) |
69
+ | Wire format | Always camelCase JSON (ch01 §3.3 invariant) — translated at boundary |
70
+ | Runtime | Python 3.10+ |
71
+ | HTTP library | httpx (sync + async; modern) |
72
+
73
+ ## License
74
+
75
+ UNLICENSED — internal to Kilimanjaro.
@@ -0,0 +1,143 @@
1
+ """
2
+ k9o — Kilimanjaro platform SDK (Python; idiomatic).
3
+
4
+ Canonical usage:
5
+
6
+ from k9o import create_client, KError
7
+
8
+ k9o = create_client(
9
+ base_url="https://acme.api.k9o.io",
10
+ api_key=os.environ["K9O_API_KEY"],
11
+ org_slug="acme",
12
+ project_slug="member-portal",
13
+ )
14
+
15
+ try:
16
+ response = k9o.from_("posts").select().limit(10).execute()
17
+ for row in response.data:
18
+ print(row)
19
+ session = k9o.gate.sign_in(email="user@example.com", password="…")
20
+ print("signed in:", session.data["user"]["id"])
21
+ except KError as e:
22
+ print(f"[{e.code}] {e.message}: {e.recommendation}")
23
+
24
+ Architectural posture: hand-authored idiomatic SDK against the platform API specification
25
+ + services/gateway/openapi.json contract source; replaces the prior
26
+ OpenAPI-generator output (`k9o_gate` raw client) with ch13 idiomatic
27
+ shape (snake_case methods + raise KError + envelope dataclass with
28
+ typed meta accessor sugar + data DSL).
29
+ """
30
+
31
+ from __future__ import annotations
32
+
33
+ from .audit import AuditNamespace
34
+ from .client import K9oClient, create_client
35
+ from .compute import ComputeNamespace, LlmsNamespace, LLM_MODEL_IDS, LLM_ERROR_CODES
36
+ from .data import FromBuilder, SelectBuilder, UpdateBuilder, DeleteBuilder
37
+ from .functions import FunctionsNamespace
38
+ from .kibo_vault import KiboNamespace, SecretsNamespace, VaultNamespace
39
+ from .me import MeNamespace
40
+ from .migrations import MigrationsNamespace
41
+ from .org import OrgNamespace
42
+ from .orgs import OrgsNamespace
43
+ from .policies import PoliciesNamespace
44
+ from .realtime import RealtimeNamespace, realtime_topic, REALTIME_TOPIC_FAMILIES
45
+ from .studio import (
46
+ StudioNamespace,
47
+ WorkflowsNamespace,
48
+ DashboardsNamespace,
49
+ WORKFLOW_ERROR_CODES,
50
+ DASHBOARD_ERROR_CODES,
51
+ WORKFLOW_TRIGGER_TYPES,
52
+ WORKFLOW_ACTION_TYPES,
53
+ WIDGET_TYPES,
54
+ )
55
+ from .envelope import (
56
+ Envelope,
57
+ Meta,
58
+ MetaContext,
59
+ MetaCursor,
60
+ MetaIdempotency,
61
+ MetaSubscription,
62
+ MetaTiming,
63
+ MetaWarning,
64
+ )
65
+ from .errors import KError, KErrorWire, kerror_from_wire
66
+ from .gate import GateNamespace
67
+ from .http import HttpClientConfig, RetryConfig
68
+ from .projects import Project, ProjectsNamespace
69
+ from .url_grammar import (
70
+ org_path,
71
+ platform_path,
72
+ project_path,
73
+ resolve_base_url,
74
+ validate_base_url,
75
+ validate_slug,
76
+ )
77
+
78
+ __version__ = "0.3.0"
79
+
80
+ __all__ = [
81
+ "__version__",
82
+ # Factory + client
83
+ "create_client",
84
+ "K9oClient",
85
+ # Error
86
+ "KError",
87
+ "KErrorWire",
88
+ "kerror_from_wire",
89
+ # Envelope + meta
90
+ "Envelope",
91
+ "Meta",
92
+ "MetaContext",
93
+ "MetaCursor",
94
+ "MetaIdempotency",
95
+ "MetaSubscription",
96
+ "MetaTiming",
97
+ "MetaWarning",
98
+ # Data DSL
99
+ "FromBuilder",
100
+ "SelectBuilder",
101
+ "UpdateBuilder",
102
+ "DeleteBuilder",
103
+ # Namespaces
104
+ "ProjectsNamespace",
105
+ "Project",
106
+ "GateNamespace",
107
+ "StudioNamespace",
108
+ "WorkflowsNamespace",
109
+ "DashboardsNamespace",
110
+ "ComputeNamespace",
111
+ "LlmsNamespace",
112
+ "RealtimeNamespace",
113
+ "realtime_topic",
114
+ "OrgNamespace",
115
+ "OrgsNamespace",
116
+ "MigrationsNamespace",
117
+ "FunctionsNamespace",
118
+ "PoliciesNamespace",
119
+ "AuditNamespace",
120
+ "MeNamespace",
121
+ "KiboNamespace",
122
+ "VaultNamespace",
123
+ "SecretsNamespace",
124
+ # P6 closed enums + error-code maps
125
+ "WORKFLOW_ERROR_CODES",
126
+ "DASHBOARD_ERROR_CODES",
127
+ "LLM_ERROR_CODES",
128
+ "WORKFLOW_TRIGGER_TYPES",
129
+ "WORKFLOW_ACTION_TYPES",
130
+ "WIDGET_TYPES",
131
+ "LLM_MODEL_IDS",
132
+ "REALTIME_TOPIC_FAMILIES",
133
+ # URL grammar
134
+ "validate_base_url",
135
+ "resolve_base_url",
136
+ "validate_slug",
137
+ "project_path",
138
+ "org_path",
139
+ "platform_path",
140
+ # HTTP config (advanced use)
141
+ "HttpClientConfig",
142
+ "RetryConfig",
143
+ ]
k9o-1.0.0/k9o/ai.py ADDED
@@ -0,0 +1,45 @@
1
+ """
2
+ AI namespace — `client.ai.*` (platform AI primitives).
3
+
4
+ Wire mapping (project-plane):
5
+ - embed(input, model=None) -> POST /@<slug>/ai/embeddings
6
+ body {model?, input: str | list[str]}
7
+ -> Envelope(data={"embeddings": [[float, ...], ...], "model": str, "dimensions": int})
8
+
9
+ Bounds (non-empty inputs, count, size, concurrency) are enforced by the
10
+ gateway, not here. The SDK sends `input` exactly as given and never puts it
11
+ in an error it constructs.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from typing import Sequence
17
+
18
+ from .envelope import Envelope
19
+ from .http import HttpClientConfig, request
20
+ from .url_grammar import project_path
21
+
22
+
23
+ def _require_project_slug(config: HttpClientConfig) -> str:
24
+ if not config.project_slug:
25
+ raise ValueError("ai operations require project_slug bound on the client")
26
+ return config.project_slug
27
+
28
+
29
+ class AiNamespace:
30
+ """`client.ai.*`."""
31
+
32
+ def __init__(self, config: HttpClientConfig) -> None:
33
+ self._config = config
34
+
35
+ def embed(self, input: str | Sequence[str], *, model: str | None = None) -> Envelope:
36
+ """POST /@<slug>/ai/embeddings — embed one string or a list of strings.
37
+
38
+ `model` is omitted from the body when None (server default). A single
39
+ string stays a string; a sequence is sent as a list, in order.
40
+ """
41
+ slug = _require_project_slug(self._config)
42
+ body: dict = {"input": input if isinstance(input, str) else list(input)}
43
+ if model is not None:
44
+ body["model"] = model
45
+ return request(self._config, method="POST", path=project_path(slug, "ai/embeddings"), body=body)
k9o-1.0.0/k9o/audit.py ADDED
@@ -0,0 +1,48 @@
1
+ """
2
+ Project-plane audit log namespace — `client.audit.*`.
3
+
4
+ Distinct from `client.org.audit_log` (org-plane) and
5
+ `client.me.audit_log` (operator-self). Python idiomatic per ch13 §2.1.1.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from datetime import datetime, timedelta, timezone
11
+ from typing import Any
12
+ from urllib.parse import quote
13
+
14
+ from .envelope import Envelope
15
+ from .http import HttpClientConfig, request
16
+ from .url_grammar import project_path
17
+
18
+
19
+ def _require_project_slug(config: HttpClientConfig) -> str:
20
+ if not config.project_slug:
21
+ raise ValueError("audit operations require project_slug bound on the client")
22
+ return config.project_slug
23
+
24
+
25
+ def _clean(d: dict[str, Any]) -> dict[str, Any]:
26
+ return {k: v for k, v in d.items() if v is not None}
27
+
28
+
29
+ class AuditNamespace:
30
+ def __init__(self, config: HttpClientConfig) -> None:
31
+ self._config = config
32
+
33
+ def query(self, *, since: str | None = None, until: str | None = None, type: str | None = None,
34
+ actor_id: str | None = None, target_kind: str | None = None, target_id: str | None = None,
35
+ limit: int | None = None, cursor: str | None = None) -> Envelope:
36
+ """Query the audit log (reverse-chronological; filters AND-compose)."""
37
+ slug = _require_project_slug(self._config)
38
+ return request(self._config, method="GET", path=project_path(slug, "audit-log"),
39
+ query=_clean({"since": since, "until": until, "type": type, "actorId": actor_id,
40
+ "targetKind": target_kind, "targetId": target_id,
41
+ "limit": limit, "cursor": cursor}))
42
+
43
+ def tail(self, *, since_minutes: int = 1, limit: int = 100) -> Envelope:
44
+ """Convenience: recent events within a since-window."""
45
+ slug = _require_project_slug(self._config)
46
+ since = (datetime.now(timezone.utc) - timedelta(minutes=since_minutes)).isoformat()
47
+ return request(self._config, method="GET", path=project_path(slug, "audit-log"),
48
+ query={"since": since, "limit": limit})
@@ -0,0 +1,20 @@
1
+ """``k9o.barbican`` — free, embeddable L2 Keep guardrail (Python).
2
+
3
+ Unicode-normalize -> Aho-Corasick deny over a signed ruleset -> buffer-and-
4
+ scan output stream-filter. A thin wrapper over the audited ``k9o-keep-core``
5
+ engine, compiled to a native lib via uniffi (mirrors the ``k9o.kibo`` crypto
6
+ wrapper's FFI shape). ZERO security logic here: every normalization pass,
7
+ deny match, verdict, and output redaction is the core's; this layer only
8
+ forwards typed calls to the generated binding and maps its error -> ``KError``.
9
+
10
+ CLAIM BOUNDARY (security-claims-non-negotiable): Barbican is advisory /
11
+ defense-in-depth (Edge Filtration). "Un-bypassable" attaches ONLY to the
12
+ Enforced Boundary (Warden as the sole sandbox egress) -- never this SDK.
13
+
14
+ The native lib + generated uniffi binding under ``_ffi/`` are build artifacts
15
+ (generated per platform; gitignored) -- same convention as ``k9o.kibo``.
16
+ """
17
+
18
+ from .barbican import Barbican, OutputFilter
19
+
20
+ __all__ = ["Barbican", "OutputFilter"]
@@ -0,0 +1,5 @@
1
+ # Generated uniffi binding + native lib live here (build artifacts, gitignored).
2
+ # Regenerate: cargo build -p k9o-keep-core-ffi-uniffi --release --features cli
3
+ # + cargo run --bin uniffi-bindgen --features cli -- generate \
4
+ # --library target/release/libk9o_keep_core_ffi_uniffi.dylib \
5
+ # --language python --out-dir .