maitento 26.11.1__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 (63) hide show
  1. maitento-26.11.1/.gitignore +8 -0
  2. maitento-26.11.1/CHANGELOG.md +120 -0
  3. maitento-26.11.1/LICENSE +202 -0
  4. maitento-26.11.1/NOTICE +5 -0
  5. maitento-26.11.1/PKG-INFO +106 -0
  6. maitento-26.11.1/README.md +69 -0
  7. maitento-26.11.1/pyproject.toml +92 -0
  8. maitento-26.11.1/route-map.json +1649 -0
  9. maitento-26.11.1/scripts/unasync.py +122 -0
  10. maitento-26.11.1/scripts/write_route_map.py +65 -0
  11. maitento-26.11.1/src/maitento/__init__.py +92 -0
  12. maitento-26.11.1/src/maitento/_aio.py +46 -0
  13. maitento-26.11.1/src/maitento/_async/__init__.py +8 -0
  14. maitento-26.11.1/src/maitento/_async/_client.py +192 -0
  15. maitento-26.11.1/src/maitento/_async/_events.py +341 -0
  16. maitento-26.11.1/src/maitento/_async/_paging.py +58 -0
  17. maitento-26.11.1/src/maitento/_async/_resources.py +2869 -0
  18. maitento-26.11.1/src/maitento/_async/_run.py +322 -0
  19. maitento-26.11.1/src/maitento/_async/_transport.py +225 -0
  20. maitento-26.11.1/src/maitento/_auth.py +186 -0
  21. maitento-26.11.1/src/maitento/_events_core.py +182 -0
  22. maitento-26.11.1/src/maitento/_generated/__init__.py +8 -0
  23. maitento-26.11.1/src/maitento/_generated/_runtime.py +181 -0
  24. maitento-26.11.1/src/maitento/_generated/models.py +18757 -0
  25. maitento-26.11.1/src/maitento/_http.py +460 -0
  26. maitento-26.11.1/src/maitento/_project.py +250 -0
  27. maitento-26.11.1/src/maitento/_route_map.py +367 -0
  28. maitento-26.11.1/src/maitento/_run_core.py +208 -0
  29. maitento-26.11.1/src/maitento/_sio.py +48 -0
  30. maitento-26.11.1/src/maitento/_sync/__init__.py +12 -0
  31. maitento-26.11.1/src/maitento/_sync/_client.py +196 -0
  32. maitento-26.11.1/src/maitento/_sync/_events.py +338 -0
  33. maitento-26.11.1/src/maitento/_sync/_paging.py +62 -0
  34. maitento-26.11.1/src/maitento/_sync/_resources.py +2873 -0
  35. maitento-26.11.1/src/maitento/_sync/_run.py +326 -0
  36. maitento-26.11.1/src/maitento/_sync/_transport.py +229 -0
  37. maitento-26.11.1/src/maitento/_uploads.py +89 -0
  38. maitento-26.11.1/src/maitento/_usage.py +63 -0
  39. maitento-26.11.1/src/maitento/_version.py +3 -0
  40. maitento-26.11.1/src/maitento/errors.py +233 -0
  41. maitento-26.11.1/src/maitento/models.py +26 -0
  42. maitento-26.11.1/src/maitento/py.typed +0 -0
  43. maitento-26.11.1/src/maitento/webhooks.py +191 -0
  44. maitento-26.11.1/tests/conftest.py +52 -0
  45. maitento-26.11.1/tests/factories.py +99 -0
  46. maitento-26.11.1/tests/fake_notifications.py +93 -0
  47. maitento-26.11.1/tests/helpers.py +50 -0
  48. maitento-26.11.1/tests/test_auth.py +288 -0
  49. maitento-26.11.1/tests/test_billing.py +57 -0
  50. maitento-26.11.1/tests/test_command.py +261 -0
  51. maitento-26.11.1/tests/test_credentials.py +375 -0
  52. maitento-26.11.1/tests/test_errors.py +175 -0
  53. maitento-26.11.1/tests/test_events.py +243 -0
  54. maitento-26.11.1/tests/test_live.py +127 -0
  55. maitento-26.11.1/tests/test_paging.py +71 -0
  56. maitento-26.11.1/tests/test_parity.py +67 -0
  57. maitento-26.11.1/tests/test_project.py +192 -0
  58. maitento-26.11.1/tests/test_retries.py +130 -0
  59. maitento-26.11.1/tests/test_route_map.py +132 -0
  60. maitento-26.11.1/tests/test_run.py +318 -0
  61. maitento-26.11.1/tests/test_runs_lane.py +35 -0
  62. maitento-26.11.1/tests/test_webhooks.py +213 -0
  63. maitento-26.11.1/tests/test_wire.py +284 -0
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .mypy_cache/
5
+ .pytest_cache/
6
+ .venv/
7
+ dist/
8
+ build/
@@ -0,0 +1,120 @@
1
+ # Changelog
2
+
3
+ All notable changes to the `maitento` Python package. Versions are shared with the other Maitento SDKs (`YY.M.N`).
4
+
5
+ ## 26.11.1 (2026-11-03)
6
+
7
+ - First release: `Maitento` (blocking) and `AsyncMaitento` (asyncio) clients covering every public API route,
8
+ `deploy()`/`validate()` for resource projects, `run()` helpers with token streaming, live events over the
9
+ `/notifications` WebSocket, typed errors, paged lists, and web-hook verification helpers.
10
+ - Deploying needs a tenant admin: anyone else is refused with a 403, code `api:builds:deploy-requires-admin`. Any
11
+ member can still `validate()`.
12
+ - A `run()` helper's errors word a run the same way in every Maitento SDK: `App run <id> ended Error: <failure
13
+ details>` (`... ended Killed.` when the run recorded nothing), and `Interaction run <id> did not finish within 2s.`
14
+ - `automations.trigger()` raises `ValidationError` with code `api:automations:start-failed` (followed by the cause's
15
+ own codes) when no action could start, instead of returning an empty process id. Creating or updating an automation
16
+ whose app action leaves out one of the app's inputs is refused with `api:automations:app-input-missing`.
17
+ - Usage: `toolCalls` (on `/usage/runs` rows and the usage totals) counts an interaction run's tool calls too; it was 0
18
+ for every interaction run.
19
+ - Starting an interaction, an app or a code pipeline takes `credential_stack` (the stack's id or name) to run on that
20
+ credential stack: its credentials serve the run, and Maitento's own keys never do. An app's stack is the stack of
21
+ every run it starts. Naming a stack and passing `credentials` at once is refused with
22
+ `api:credential-stacks:with-credentials`; naming one the tenant hasn't got, with `api:credential-stacks:unknown`.
23
+ - Interactions, apps and code pipelines can name their own credential stack (`credential_stack` on their versions and
24
+ on the interaction update and pipeline create requests; `credentialStack` in an `.mtr` file or `pipeline-definition.json`):
25
+ runs that don't name one at the start use it before the namespace's and the tenant's default.
26
+ - `credentials` and `credential_stacks` manage the tenant's own model credentials and the stacks runs use them
27
+ through. `credentials`: `list(tag=)`, `get`, `find`, `create`, `update`, `delete`, `delete_by_tag` (returns how
28
+ many), `test`, and `start_sign_in`/`finish_sign_in` to sign a Claude Code or Codex subscription in as a credential.
29
+ Keys are write-only: only each key's `key_hint` is served; an update keeps a key sent by `id` alone, or with the value
30
+ it already has. `credential_stacks`: `list`, `get`, `find`, `create`,
31
+ `update`, `delete`, and `get_tenant_default`/`set_tenant_default` and
32
+ `get_namespace_default`/`set_namespace_default` (`None` clears a default).
33
+ - An Anthropic credential can reach Claude on Amazon Bedrock or Google Vertex AI: `cloud={"kind": "Bedrock",
34
+ "awsRegion": ...}` or `{"kind": "Vertex", "gcpProjectId": ..., "gcpRegion": ...}` (endpoint kinds `Bedrock` and
35
+ `Vertex`), with the Bedrock API key or the service account's JSON key file as its key. Only code pipelines' Claude Code
36
+ agents run on it; testing it answers `api:credentials:test-not-supported`; a cloud that can't be reached is refused
37
+ with `api:credentials:cloud-invalid`.
38
+ - On a credential stack, a model an agent override defines inline (`custom_model`) and a coding agent on your own
39
+ endpoint (`CustomAnthropic`, `CustomOpenAiResponses`, `CustomOpenAiChat`) run on the stack's credentials that have
40
+ their own endpoint, for the model's API, and name the model in `models`; they had no credential on a stack before.
41
+ - `credential_stacks.find_by_name(name)` (`GET /credential-stacks/by-name/{name}`): a stack by its name, or `None`.
42
+ - `credentials.test_unsaved(...)` (`POST /credentials/test`): tests a credential before saving it, with what `create`
43
+ takes, and stores nothing.
44
+ - `credential_stacks.usage(id)` (`GET /credential-stacks/by-id/{id}/usage`): whether a stack is the tenant's default,
45
+ the namespaces whose default it is, and the knowledge bases that embed with it.
46
+ - `credentials.import_sign_in(tool=, access_token=, refresh_token=, expires_at_utc=, id_token=)` makes an OAuth
47
+ credential from a sign-in whose tokens you already hold, and `replace_sign_in_tokens(id, ...)` swaps them after you
48
+ refresh: Maitento never refreshes such a sign-in itself (`oauth.refreshed_by_caller`). Each route refuses the other
49
+ kind of sign-in (`api:credentials:sign-in-refreshed-here`, `api:credentials:sign-in-refreshed-by-caller`).
50
+ - An automation's `app` and `interaction` actions take `credential_stack` (the stack's id or name) for the runs they
51
+ start, as a `codepipeline` action's `request` does. Saving an action that names a stack the tenant hasn't got is
52
+ refused with `api:credential-stacks:unknown`; a pipeline action with a stack and `credentials` of its own, with
53
+ `api:credential-stacks:with-credentials`.
54
+ - `partitions.set_embedding_credential_stack(id, stack_id)` (`None` clears it): a knowledge base embeds on its own
55
+ credential stack (`embedding_credential_stack_id` on `Partition`), after its own embedding keys and in place of the
56
+ tenant's model keys and default stack, never on Maitento's key. Deleting a stack a knowledge base embeds with is
57
+ refused with `api:credential-stacks:in-use-by-partition`.
58
+ - A `NotFoundError` from starting a run by name, or from naming a namespace that does not exist, says what was not
59
+ found (`Interaction 'brainstorm' was not found in namespace 'demo'.`): the 404 now carries it as `{ error }`.
60
+ - Stable error codes for a refused interaction start (`api:interactions:input-required`, `input-empty`,
61
+ `input-invalid`, `input-unknown`, `not-found`, `no-enabled-version`, `response-schema-invalid`,
62
+ `swarm-limits-invalid`, `loom-*`, `ai-model-override-invalid`), for deleting a knowledge base that still holds files
63
+ (`api:partition:not-empty`), and for refused embedding credentials. They used to be derived from the request member
64
+ (`request`, `id`, `credentials`). The messages name the interaction rather than its id.
65
+ - A required tool-binding or auth input with a default no longer refuses a run that leaves it out: the run uses the
66
+ default (shown in the run's inputs), as it does when the input is passed empty.
67
+ - An interaction created through the API without `contextSettings` gets the same context defaults as one deployed
68
+ from a `.mtr` file with no `context` block (`Automatic` trimming, a 32,000-token reply cap); it used to get
69
+ `FailOnOverflow` and the model's full reply.
70
+ - Files: `IngestedFile.indexingFailure` (and on file listings): why a file can't be indexed until someone acts, as a
71
+ `code` (`api:embeddings:fallback-not-permitted` when there is no embedding key, `api:embeddings:credentials-exhausted`
72
+ when every key failed), a `message` and `dateFailed`. Cleared once the file is indexed. Searching a knowledge base
73
+ that can't embed is refused with `api:embeddings:fallback-not-permitted` instead of returning no results.
74
+ - Files of a knowledge base with no embedding key it may use wait instead of being retried every few minutes, and start
75
+ again once a key, a credential stack or consent to Maitento's key is added. Such a knowledge base carries one
76
+ `PartitionEmbeddingCredentialFailure` with `failure_reason` `IndexingDisabled` and `credential_id` `maitento-fallback`
77
+ (listed by `GET /partitions/embedding-credential-failures`), so you can tell your admins.
78
+ - `capsule_runs.exec_and_wait(id, command, arguments, timeout=..., abort=...)` queues a command and waits for it to
79
+ end, over live events when a stream is open and by polling the one command otherwise; it returns the command with
80
+ its exit code and output, and raises the new `CapsuleCommandAbortedError` when the capsule ends first.
81
+ `capsule_runs.get_command(id, command_id)` reads one command (`GET /capsule-processes/by-id/{id}/commands/{commandId}`).
82
+ - Secrets are write-only: `secrets.value(name)` and its route, `GET /secrets/by-name/{name}/value`, are removed, so
83
+ nothing reads a stored value back. Replace a value with `secrets.update` instead.
84
+ - Code pipeline repositories take `is_read_only` (`isReadOnly` in the API): a read-only repository is cloned as context for
85
+ the agents, but a run never commits, pushes or diffs it. It defaults to `false`.
86
+ - `tenant.set_retention(hours=)`: a tenant admin sets how long finished runs are kept, up to the plan's maximum (the new
87
+ `plan_max_hours` in `tenant.retention()`); `hours=None` goes back to the platform default. A retained run is kept for
88
+ at most the plan's maximum, and its retention status says when that is (`lease_ends_at_utc`).
89
+ - `runs.lane(id, type=)`: whether a run is waiting for a lane before it starts, since when, why (`LANES_IN_USE` or
90
+ `PLATFORM_BUSY`), and how many of your runs are ahead of it. Runs and run lists carry `waiting_for_lane_since_utc`.
91
+ - `billing`: the tenant's plan and billing. `standing()` (the plan and its state, the balance, whether work can start,
92
+ any plan change on its way, and this month's use of each allowance), `plan()`, `balance()`, `catalogue()` (the
93
+ plans on sale), `notices(limit=)`, and the balance settings: `auto_top_up()` / `set_auto_top_up()` and `alerts()` /
94
+ `set_alerts()`. Buying a plan or credit, and changing the plan, stay in the portal. The standing also says when the
95
+ balance is low (`low_balance`, by the alert settings) and when the subscription renews (`term_ends_at_utc`).
96
+ - `TenantRegisterRequest`: `code` is optional, and there's a new `turnstileToken`. Where sign-up is open, a tenant can be
97
+ registered without an invitation code, with the sign-up page's Cloudflare Turnstile token instead.
98
+ - Sign-in with GitHub, Google and Microsoft is a portal flow under `/auth/sso`, which the SDK doesn't wrap (an SDK
99
+ client has no browser to send to a provider). Its request and response models are generated: `SsoProvider`,
100
+ `SsoProvidersResponse` (with `sign_up_open` and the `start_base_url` a sign-in starts from), `SsoExchangeRequest`
101
+ and `SsoConfirmLinkRequest`.
102
+ - A `Billing` webhook type: a `BillingNotice` is delivered when your tenant runs out of credit or gets it back
103
+ (`OutOfCredit`, `CreditRestored`), uses up an allowance (`AllowanceUsed`), runs low (`LowBalance`), its plan changes
104
+ (`PlanChanged`, `PlanRestored`, `MovedToFree`), a renewal payment fails (`PaymentFailed`, then `FreezeReminder` and
105
+ `FreezeEnded`), or an automatic top-up can't be charged (`AutoTopUpFailed`). It carries the `meter`, `balance`,
106
+ `currency`, `tier`, `previousTier` and `frozenUntilUtc` where they apply.
107
+ - Web-hook deliveries are signed. `verify_webhook(headers, body, secret, *, tolerance=300, now=None)` now checks
108
+ `X-MT-WebHook-Signature` (`v1=` and the HMAC-SHA256 of `"{timestamp}." + body`, keyed with your secret) against the
109
+ **raw** body, and refuses a delivery whose `X-MT-WebHook-Timestamp` is more than 5 minutes from now, so a delivery
110
+ can't be forged by someone who saw another, or replayed. `sign_webhook(secret, timestamp, body)` makes the `v1=`
111
+ value, for your receiver's tests; `maitento.webhooks` has `TIMESTAMP_HEADER`, `SIGNATURE_HEADER` and
112
+ `DEFAULT_TOLERANCE`. `parse_webhook(headers, body, secret=...)` verifies the signature the same way (so `body` must
113
+ then be raw). This replaces `verify_webhook(headers, secret)`, which compared the plain `X-MT-WebHook-Secret`
114
+ header: that header isn't sent to new webhooks, and the SDK no longer accepts it (`SECRET_HEADER` is gone). (A
115
+ breaking change, made before the first release.)
116
+ - A `WebHookRegistration` has `signed_only`: `True` when its deliveries are only signed, as for every webhook
117
+ registered now, and `False` for one registered before deliveries were signed, which also gets its secret in
118
+ `X-MT-WebHook-Secret`. `webhooks.update(id, url=..., signed_only=True)` stops such a webhook sending its secret, in
119
+ place: there's no need to delete it and register it again. It can't be undone, and `False` or leaving it out changes
120
+ nothing. The `mt` CLI does the same with `mt webhook-set ... --signed-only`.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ Maitento Python SDK
2
+ Copyright 2026 Brunelly Ltd
3
+
4
+ This product includes software developed by Maitento (https://docs.maitento.com).
5
+ Licensed under the Apache License, Version 2.0 (see LICENSE).
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.5
2
+ Name: maitento
3
+ Version: 26.11.1
4
+ Summary: The official Python SDK for Maitento, the AI OS: deploy agents and interactions, run them, and follow them live.
5
+ Project-URL: Homepage, https://docs.maitento.com
6
+ Project-URL: Documentation, https://docs.maitento.com
7
+ Project-URL: Repository, https://github.com/maitento/maitento
8
+ Project-URL: Changelog, https://github.com/maitento/maitento/blob/main/sdks/python/CHANGELOG.md
9
+ Author: Maitento
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: agents,ai,interactions,llm,maitento,sdk
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Framework :: AsyncIO
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.10
28
+ Requires-Dist: httpx<1,>=0.27
29
+ Requires-Dist: pydantic<3,>=2.9
30
+ Requires-Dist: websockets>=13.0
31
+ Provides-Extra: dev
32
+ Requires-Dist: mypy==2.4.0; extra == 'dev'
33
+ Requires-Dist: pytest-asyncio==1.4.0; extra == 'dev'
34
+ Requires-Dist: pytest==9.1.1; extra == 'dev'
35
+ Requires-Dist: respx==0.23.1; extra == 'dev'
36
+ Description-Content-Type: text/markdown
37
+
38
+ <p align="center"><img src="https://docs.maitento.com/brand/logo-horizontal-on-light-600.png" alt="maitento" width="240"></p>
39
+
40
+ # Maitento Python SDK
41
+
42
+ The official Python SDK for [Maitento](https://docs.maitento.com), the AI OS: deploy agents and interactions, run
43
+ them, stream their answers, and react to what they do.
44
+
45
+ ```bash
46
+ pip install maitento
47
+ ```
48
+
49
+ Python 3.10 or newer. It depends on `httpx`, `pydantic` (v2) and `websockets`.
50
+
51
+ ## Quick start
52
+
53
+ ```python
54
+ from maitento import Maitento
55
+
56
+ mt = Maitento() # reads MAITENTO_API_KEY, MAITENTO_BASE_URL, MAITENTO_NAMESPACE
57
+ mt.deploy("./maitento") # the resource project folder
58
+ run = mt.interactions.run("hello") # start, wait, return the finished run
59
+ print(run.output)
60
+ ```
61
+
62
+ `MAITENTO_API_KEY` is `"<userId>:<secret>"`, as the portal shows it: the id of the user that owns the key, a colon,
63
+ then the secret. The same code runs on asyncio with `AsyncMaitento` and `await`:
64
+
65
+ ```python
66
+ import asyncio
67
+ from maitento import AsyncMaitento
68
+
69
+ async def main() -> None:
70
+ async with AsyncMaitento() as mt:
71
+ run = await mt.interactions.run(
72
+ "haiku",
73
+ inputs={"topic": "autumn"},
74
+ on_token=lambda text, agent: print(text, end="", flush=True),
75
+ )
76
+ print("\n", run.status)
77
+
78
+ asyncio.run(main())
79
+ ```
80
+
81
+ ## What is in it
82
+
83
+ - **Every API resource** as a method group: `namespaces`, `models`, `model_keys`, `agents`, `interactions`,
84
+ `interaction_runs`, `apps`, `app_runs`, `capsules`, `capsule_runs`, `pipelines`, `pipeline_runs`, `runs`,
85
+ `connectors`, `tools`, `secrets`, `webhooks`, `partitions`, `files`, `vfs`, `looms`, `automations`, `builds`,
86
+ `usage`, `users`, `api_keys`, `invitations`, `tenant`, `events`.
87
+ - **`get` vs `find`**: `get…` raises `NotFoundError`; `find…` returns `None`.
88
+ - **`run()` helpers** for interactions, apps, capsules and pipelines: start once (never retried), follow the run
89
+ over the live event socket or by polling, call `on_token` / `on_update` / `on_waiting`, and return the finished run
90
+ (or raise `ProcessFailedError`).
91
+ - **Live events** (`mt.events.connect()`): callbacks with `on(...)` or a plain `for event in stream` loop, with
92
+ automatic pings, reconnects and a `reconnected` event.
93
+ - **Typed errors** (`ValidationError`, `NotFoundError`, `RateLimitError`, ...), all derived from `MaitentoError`.
94
+ Calls that only read are retried on network errors, 429 and 502/503/504, honouring `Retry-After`.
95
+ - **Paged lists** you can iterate across pages: `for run in mt.runs.list(state="Terminal"): ...`
96
+ - **Web-hook helpers** for your receiver: `verify_webhook(headers, body, secret)` checks a delivery's signature from
97
+ its raw body, and `parse_webhook(headers, body)` reads it.
98
+ - **Generated wire models** (pydantic v2) that tolerate new fields and new enum values from a newer server.
99
+
100
+ ## Links
101
+
102
+ - Documentation: <https://docs.maitento.com>
103
+ - Source: <https://github.com/maitento/maitento>
104
+ - Changelog: [CHANGELOG.md](https://github.com/maitento/maitento/blob/main/sdks/python/CHANGELOG.md)
105
+
106
+ Licensed under the Apache License, Version 2.0.
@@ -0,0 +1,69 @@
1
+ <p align="center"><img src="https://docs.maitento.com/brand/logo-horizontal-on-light-600.png" alt="maitento" width="240"></p>
2
+
3
+ # Maitento Python SDK
4
+
5
+ The official Python SDK for [Maitento](https://docs.maitento.com), the AI OS: deploy agents and interactions, run
6
+ them, stream their answers, and react to what they do.
7
+
8
+ ```bash
9
+ pip install maitento
10
+ ```
11
+
12
+ Python 3.10 or newer. It depends on `httpx`, `pydantic` (v2) and `websockets`.
13
+
14
+ ## Quick start
15
+
16
+ ```python
17
+ from maitento import Maitento
18
+
19
+ mt = Maitento() # reads MAITENTO_API_KEY, MAITENTO_BASE_URL, MAITENTO_NAMESPACE
20
+ mt.deploy("./maitento") # the resource project folder
21
+ run = mt.interactions.run("hello") # start, wait, return the finished run
22
+ print(run.output)
23
+ ```
24
+
25
+ `MAITENTO_API_KEY` is `"<userId>:<secret>"`, as the portal shows it: the id of the user that owns the key, a colon,
26
+ then the secret. The same code runs on asyncio with `AsyncMaitento` and `await`:
27
+
28
+ ```python
29
+ import asyncio
30
+ from maitento import AsyncMaitento
31
+
32
+ async def main() -> None:
33
+ async with AsyncMaitento() as mt:
34
+ run = await mt.interactions.run(
35
+ "haiku",
36
+ inputs={"topic": "autumn"},
37
+ on_token=lambda text, agent: print(text, end="", flush=True),
38
+ )
39
+ print("\n", run.status)
40
+
41
+ asyncio.run(main())
42
+ ```
43
+
44
+ ## What is in it
45
+
46
+ - **Every API resource** as a method group: `namespaces`, `models`, `model_keys`, `agents`, `interactions`,
47
+ `interaction_runs`, `apps`, `app_runs`, `capsules`, `capsule_runs`, `pipelines`, `pipeline_runs`, `runs`,
48
+ `connectors`, `tools`, `secrets`, `webhooks`, `partitions`, `files`, `vfs`, `looms`, `automations`, `builds`,
49
+ `usage`, `users`, `api_keys`, `invitations`, `tenant`, `events`.
50
+ - **`get` vs `find`**: `get…` raises `NotFoundError`; `find…` returns `None`.
51
+ - **`run()` helpers** for interactions, apps, capsules and pipelines: start once (never retried), follow the run
52
+ over the live event socket or by polling, call `on_token` / `on_update` / `on_waiting`, and return the finished run
53
+ (or raise `ProcessFailedError`).
54
+ - **Live events** (`mt.events.connect()`): callbacks with `on(...)` or a plain `for event in stream` loop, with
55
+ automatic pings, reconnects and a `reconnected` event.
56
+ - **Typed errors** (`ValidationError`, `NotFoundError`, `RateLimitError`, ...), all derived from `MaitentoError`.
57
+ Calls that only read are retried on network errors, 429 and 502/503/504, honouring `Retry-After`.
58
+ - **Paged lists** you can iterate across pages: `for run in mt.runs.list(state="Terminal"): ...`
59
+ - **Web-hook helpers** for your receiver: `verify_webhook(headers, body, secret)` checks a delivery's signature from
60
+ its raw body, and `parse_webhook(headers, body)` reads it.
61
+ - **Generated wire models** (pydantic v2) that tolerate new fields and new enum values from a newer server.
62
+
63
+ ## Links
64
+
65
+ - Documentation: <https://docs.maitento.com>
66
+ - Source: <https://github.com/maitento/maitento>
67
+ - Changelog: [CHANGELOG.md](https://github.com/maitento/maitento/blob/main/sdks/python/CHANGELOG.md)
68
+
69
+ Licensed under the Apache License, Version 2.0.
@@ -0,0 +1,92 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.26"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "maitento"
7
+ dynamic = ["version"]
8
+ description = "The official Python SDK for Maitento, the AI OS: deploy agents and interactions, run them, and follow them live."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE", "NOTICE"]
13
+ authors = [{ name = "Maitento" }]
14
+ keywords = ["maitento", "ai", "agents", "llm", "sdk", "interactions"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Framework :: AsyncIO",
27
+ "Topic :: Software Development :: Libraries :: Python Modules",
28
+ "Typing :: Typed",
29
+ ]
30
+ # Lower bounds are releases that have been widely available for a long time (httpx 0.27: Feb 2024,
31
+ # pydantic 2.9: Sep 2024, websockets 13.0: Aug 2024 — the first with the `websockets.asyncio` client).
32
+ dependencies = [
33
+ "httpx>=0.27,<1",
34
+ "pydantic>=2.9,<3",
35
+ "websockets>=13.0",
36
+ ]
37
+
38
+ [project.optional-dependencies]
39
+ # Pinned so a contributor's run matches CI. Every pin was released at least two weeks before 2026-10-26.
40
+ dev = [
41
+ "pytest==9.1.1",
42
+ "pytest-asyncio==1.4.0",
43
+ "respx==0.23.1",
44
+ "mypy==2.4.0",
45
+ ]
46
+
47
+ [project.urls]
48
+ Homepage = "https://docs.maitento.com"
49
+ Documentation = "https://docs.maitento.com"
50
+ Repository = "https://github.com/maitento/maitento"
51
+ Changelog = "https://github.com/maitento/maitento/blob/main/sdks/python/CHANGELOG.md"
52
+
53
+ [tool.hatch.version]
54
+ path = "src/maitento/_version.py"
55
+
56
+ [tool.hatch.build.targets.wheel]
57
+ packages = ["src/maitento"]
58
+
59
+ [tool.hatch.build.targets.sdist]
60
+ include = [
61
+ "src/maitento",
62
+ "tests",
63
+ "scripts",
64
+ "README.md",
65
+ "CHANGELOG.md",
66
+ "LICENSE",
67
+ "NOTICE",
68
+ "route-map.json",
69
+ "pyproject.toml",
70
+ ]
71
+
72
+ [tool.pytest.ini_options]
73
+ testpaths = ["tests"]
74
+ asyncio_mode = "auto"
75
+ asyncio_default_fixture_loop_scope = "function"
76
+ addopts = "-m 'not live' -p no:cacheprovider"
77
+ markers = [
78
+ "live: calls a running Maitento API (needs MAITENTO_BASE_URL, MAITENTO_API_KEY and MAITENTO_TEST_DEEPSEEK_KEY); run with `pytest -m live`",
79
+ ]
80
+ filterwarnings = ["error"]
81
+
82
+ [tool.mypy]
83
+ python_version = "3.10"
84
+ strict = true
85
+ files = ["src/maitento"]
86
+ plugins = ["pydantic.mypy"]
87
+ cache_dir = "/tmp/.mypy_cache"
88
+
89
+ [[tool.mypy.overrides]]
90
+ # Generated from the server's wire contract; regenerated, never hand-edited.
91
+ module = ["maitento._generated.*"]
92
+ ignore_errors = true