matrx-api 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.
- matrx_api-0.1.0/.gitignore +345 -0
- matrx_api-0.1.0/PKG-INFO +56 -0
- matrx_api-0.1.0/README.md +40 -0
- matrx_api-0.1.0/matrx_api/__init__.py +31 -0
- matrx_api-0.1.0/matrx_api/client.py +420 -0
- matrx_api-0.1.0/matrx_api/credentials.py +105 -0
- matrx_api-0.1.0/matrx_api/deployments.py +122 -0
- matrx_api-0.1.0/matrx_api/errors.py +88 -0
- matrx_api-0.1.0/matrx_api/generated/__init__.py +1 -0
- matrx_api-0.1.0/matrx_api/generated/account.py +1110 -0
- matrx_api-0.1.0/matrx_api/generated/agents.py +1000 -0
- matrx_api-0.1.0/matrx_api/generated/ai.py +181 -0
- matrx_api-0.1.0/matrx_api/generated/apps.py +651 -0
- matrx_api-0.1.0/matrx_api/generated/architecture.py +2071 -0
- matrx_api-0.1.0/matrx_api/generated/audio.py +371 -0
- matrx_api-0.1.0/matrx_api/generated/chat.py +900 -0
- matrx_api-0.1.0/matrx_api/generated/code.py +951 -0
- matrx_api-0.1.0/matrx_api/generated/commerce.py +30 -0
- matrx_api-0.1.0/matrx_api/generated/communications.py +460 -0
- matrx_api-0.1.0/matrx_api/generated/computer.py +541 -0
- matrx_api-0.1.0/matrx_api/generated/content.py +700 -0
- matrx_api-0.1.0/matrx_api/generated/crm.py +440 -0
- matrx_api-0.1.0/matrx_api/generated/data.py +630 -0
- matrx_api-0.1.0/matrx_api/generated/education.py +40 -0
- matrx_api-0.1.0/matrx_api/generated/files.py +2261 -0
- matrx_api-0.1.0/matrx_api/generated/human_resources.py +290 -0
- matrx_api-0.1.0/matrx_api/generated/integrations.py +8920 -0
- matrx_api-0.1.0/matrx_api/generated/intelligence.py +1000 -0
- matrx_api-0.1.0/matrx_api/generated/knowledge.py +1910 -0
- matrx_api-0.1.0/matrx_api/generated/legal.py +370 -0
- matrx_api-0.1.0/matrx_api/generated/marketing.py +2300 -0
- matrx_api-0.1.0/matrx_api/generated/masterwork.py +510 -0
- matrx_api-0.1.0/matrx_api/generated/media.py +1021 -0
- matrx_api-0.1.0/matrx_api/generated/platform.py +250 -0
- matrx_api-0.1.0/matrx_api/generated/publish.py +410 -0
- matrx_api-0.1.0/matrx_api/generated/web.py +1771 -0
- matrx_api-0.1.0/matrx_api/generated/workflows.py +1411 -0
- matrx_api-0.1.0/matrx_api/streams.py +109 -0
- matrx_api-0.1.0/pyproject.toml +38 -0
- matrx_api-0.1.0/scripts/generate.py +264 -0
- matrx_api-0.1.0/tests/conftest.py +5 -0
- matrx_api-0.1.0/tests/test_client.py +231 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
*.pyc
|
|
2
|
+
secrets/
|
|
3
|
+
ignore/
|
|
4
|
+
temp/
|
|
5
|
+
logs/
|
|
6
|
+
# The broad `logs/` rule above is for RUNTIME log output, but it also matched
|
|
7
|
+
# the dashboard's SOURCE directory and silently swallowed an entire feature's
|
|
8
|
+
# files (only the pre-existing index.tsx stayed tracked), breaking the prod
|
|
9
|
+
# Docker build with "Could not resolve ./structured-tab". Re-include the source.
|
|
10
|
+
!apps/dashboard/src/features/logs/
|
|
11
|
+
!apps/dashboard/src/features/logs/**
|
|
12
|
+
todo
|
|
13
|
+
text_notes/
|
|
14
|
+
aidream/secrets/2.env
|
|
15
|
+
automation_matrix/matrix_processing/temp/*
|
|
16
|
+
cd
|
|
17
|
+
# Byte-compiled / optimized / DLL files
|
|
18
|
+
__pycache__/
|
|
19
|
+
*.py[cod]
|
|
20
|
+
*$py.class
|
|
21
|
+
|
|
22
|
+
# C extensions
|
|
23
|
+
*.so
|
|
24
|
+
.venv/
|
|
25
|
+
|
|
26
|
+
# Distribution / packaging
|
|
27
|
+
.Python
|
|
28
|
+
build/
|
|
29
|
+
develop-eggs/
|
|
30
|
+
dist/
|
|
31
|
+
downloads/
|
|
32
|
+
eggs/
|
|
33
|
+
.eggs/
|
|
34
|
+
lib/
|
|
35
|
+
lib64/
|
|
36
|
+
# The blanket lib/ rule above is from the standard Python .gitignore template
|
|
37
|
+
# and was silently swallowing TS source under the SPA `src/lib/` folders.
|
|
38
|
+
# Re-allow them explicitly so frontend builds don't ship without their lib layer.
|
|
39
|
+
!apps/dashboard/src/lib/
|
|
40
|
+
!apps/dashboard/src/lib/**
|
|
41
|
+
!apps/dashboard/src/features/crawler/lib/
|
|
42
|
+
!apps/dashboard/src/features/crawler/lib/**
|
|
43
|
+
!apps/workflow-studio/src/lib/
|
|
44
|
+
!apps/workflow-studio/src/lib/**
|
|
45
|
+
parts/
|
|
46
|
+
sdist/
|
|
47
|
+
var/
|
|
48
|
+
wheels/
|
|
49
|
+
share/python-wheels/
|
|
50
|
+
*.egg-info/
|
|
51
|
+
.installed.cfg
|
|
52
|
+
*.egg
|
|
53
|
+
MANIFEST
|
|
54
|
+
|
|
55
|
+
# PyInstaller
|
|
56
|
+
# Usually these files are written by a python script from a template
|
|
57
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
58
|
+
*.manifest
|
|
59
|
+
*.spec
|
|
60
|
+
|
|
61
|
+
# Installer logs
|
|
62
|
+
pip-log.txt
|
|
63
|
+
pip-delete-this-directory.txt
|
|
64
|
+
|
|
65
|
+
# Unit test / coverage reports
|
|
66
|
+
ai/tests/clean_response.json
|
|
67
|
+
ai/tests/cx_storage_response.json
|
|
68
|
+
ai/tests/execution_test.py
|
|
69
|
+
ai/tests/final_response.json
|
|
70
|
+
htmlcov/
|
|
71
|
+
.tox/
|
|
72
|
+
.nox/
|
|
73
|
+
.coverage
|
|
74
|
+
.coverage.*
|
|
75
|
+
.cache
|
|
76
|
+
nosetests.xml
|
|
77
|
+
coverage.xml
|
|
78
|
+
*.cover
|
|
79
|
+
*.py,cover
|
|
80
|
+
.hypothesis/
|
|
81
|
+
.pytest_cache/
|
|
82
|
+
cover/
|
|
83
|
+
|
|
84
|
+
# Translations
|
|
85
|
+
*.mo
|
|
86
|
+
*.pot
|
|
87
|
+
|
|
88
|
+
# Django stuff:
|
|
89
|
+
*.log
|
|
90
|
+
local_settings.py
|
|
91
|
+
db.sqlite3
|
|
92
|
+
db.sqlite3-journal
|
|
93
|
+
|
|
94
|
+
# Flask stuff:
|
|
95
|
+
instance/
|
|
96
|
+
.webassets-cache
|
|
97
|
+
|
|
98
|
+
# Scrapy stuff:
|
|
99
|
+
.scrapy
|
|
100
|
+
|
|
101
|
+
# Sphinx documentation
|
|
102
|
+
docs/_build/
|
|
103
|
+
|
|
104
|
+
# PyBuilder
|
|
105
|
+
.pybuilder/
|
|
106
|
+
target/
|
|
107
|
+
|
|
108
|
+
# Jupyter Notebook
|
|
109
|
+
.ipynb_checkpoints
|
|
110
|
+
|
|
111
|
+
# IPython
|
|
112
|
+
profile_default/
|
|
113
|
+
ipython_config.py
|
|
114
|
+
|
|
115
|
+
# pyenv
|
|
116
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
117
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
118
|
+
# .python-version
|
|
119
|
+
|
|
120
|
+
# pipenv
|
|
121
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
122
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
123
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
124
|
+
# install all needed dependencies.
|
|
125
|
+
#Pipfile.lock
|
|
126
|
+
|
|
127
|
+
# poetry
|
|
128
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
129
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
130
|
+
# commonly ignored for libraries.
|
|
131
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
132
|
+
|
|
133
|
+
# pdm
|
|
134
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
135
|
+
#pdm.lock
|
|
136
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
137
|
+
# in version control.
|
|
138
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
139
|
+
.pdm.toml
|
|
140
|
+
|
|
141
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
142
|
+
__pypackages__/
|
|
143
|
+
|
|
144
|
+
# Celery stuff
|
|
145
|
+
celerybeat-schedule
|
|
146
|
+
celerybeat.pid
|
|
147
|
+
|
|
148
|
+
# SageMath parsed files
|
|
149
|
+
*.sage.py
|
|
150
|
+
|
|
151
|
+
# Environments
|
|
152
|
+
.env
|
|
153
|
+
.env_remote
|
|
154
|
+
.venv
|
|
155
|
+
env/
|
|
156
|
+
venv/
|
|
157
|
+
ENV/
|
|
158
|
+
env.bak/
|
|
159
|
+
venv.bak/
|
|
160
|
+
.env.armanonly
|
|
161
|
+
|
|
162
|
+
# Spyder project settings
|
|
163
|
+
.spyderproject
|
|
164
|
+
.spyproject
|
|
165
|
+
|
|
166
|
+
# Rope project settings
|
|
167
|
+
.ropeproject
|
|
168
|
+
|
|
169
|
+
# mkdocs documentation
|
|
170
|
+
/site
|
|
171
|
+
|
|
172
|
+
# mypy
|
|
173
|
+
.mypy_cache/
|
|
174
|
+
.dmypy.json
|
|
175
|
+
dmypy.json
|
|
176
|
+
|
|
177
|
+
# Pyre type checker
|
|
178
|
+
.pyre/
|
|
179
|
+
|
|
180
|
+
# random armani files
|
|
181
|
+
/armani_dev/secrets/
|
|
182
|
+
/armani/
|
|
183
|
+
/_armani/
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# pytype static type analyzer
|
|
188
|
+
.pytype/
|
|
189
|
+
|
|
190
|
+
# Cython debug symbols
|
|
191
|
+
cython_debug/
|
|
192
|
+
|
|
193
|
+
.idea/
|
|
194
|
+
.vscode/
|
|
195
|
+
/node_modules/
|
|
196
|
+
|
|
197
|
+
# Frontend pnpm workspace (apps/) — node_modules at the workspace root and any
|
|
198
|
+
# member, plus Vite caches and build output. The unified lockfile (apps/pnpm-lock.yaml)
|
|
199
|
+
# IS committed; everything below is regenerated.
|
|
200
|
+
#
|
|
201
|
+
# 🚨 BOTH SPELLINGS. `node_modules/` with the slash matches a DIRECTORY only, so
|
|
202
|
+
# a SYMLINK named `node_modules` slipped straight past it: five of them — each
|
|
203
|
+
# an absolute path into one machine's checkout — were committed on main and
|
|
204
|
+
# broke `pnpm install --frozen-lockfile` on every CI runner, where the symlink
|
|
205
|
+
# is dangling and pnpm's `mkdir` of it answers ENOENT. Every package release was
|
|
206
|
+
# blocked by it. The bare spelling below matches the symlink too.
|
|
207
|
+
node_modules
|
|
208
|
+
node_modules/
|
|
209
|
+
apps/**/.vite/
|
|
210
|
+
apps/**/dist/
|
|
211
|
+
.vite/
|
|
212
|
+
|
|
213
|
+
dump.rdb
|
|
214
|
+
|
|
215
|
+
frontend/
|
|
216
|
+
|
|
217
|
+
# AME Temp Files and directory structure
|
|
218
|
+
# Ignore all files in the temp directory and its subdirectories
|
|
219
|
+
/temp/**/*
|
|
220
|
+
/tmp/**/*
|
|
221
|
+
|
|
222
|
+
# Allow .gitkeep files to retain directory structure
|
|
223
|
+
!/temp/**/.gitkeep
|
|
224
|
+
!/tmp/**/.gitkeep
|
|
225
|
+
|
|
226
|
+
# Armani
|
|
227
|
+
.history*
|
|
228
|
+
.history/
|
|
229
|
+
/local_data/
|
|
230
|
+
local_reports_data/
|
|
231
|
+
webscraper/quick_scrapes/temp/
|
|
232
|
+
automation_matrix/ai_apis/fireworks/_dev/*
|
|
233
|
+
automation_matrix/ai_apis/fireworks/_dev/fireworks_sample.py
|
|
234
|
+
*.pdf
|
|
235
|
+
*.flac
|
|
236
|
+
*.mp3
|
|
237
|
+
*.wav
|
|
238
|
+
miniconda.sh
|
|
239
|
+
/database/python_sql/temp_data/
|
|
240
|
+
.history*
|
|
241
|
+
.history/
|
|
242
|
+
.history/
|
|
243
|
+
|
|
244
|
+
_dev/
|
|
245
|
+
/_dev/
|
|
246
|
+
requirements_filtered.txt
|
|
247
|
+
|
|
248
|
+
# matrx-dev-tools backups
|
|
249
|
+
.env-backups/
|
|
250
|
+
# Matrx Ship config (contains API key)
|
|
251
|
+
.matrx-ship.json
|
|
252
|
+
|
|
253
|
+
# Matrx config (contains API keys)
|
|
254
|
+
.matrx.json
|
|
255
|
+
.matrx-tools.conf
|
|
256
|
+
|
|
257
|
+
# Claude Code local worktrees and per-user settings
|
|
258
|
+
.claude/worktrees/
|
|
259
|
+
.worktrees/
|
|
260
|
+
.claude/settings.local.json
|
|
261
|
+
|
|
262
|
+
# Append-only snapshots from matrx_utils.update_history (unbounded; do not commit)
|
|
263
|
+
common/utils/data_in_code/data_history.json
|
|
264
|
+
packages/matrx-utils/matrx_utils/data_in_code/data_history.json
|
|
265
|
+
|
|
266
|
+
# Tool-dispatch debug logs — one file per server start, never committed
|
|
267
|
+
.matrx-debug/
|
|
268
|
+
# Per-definition BEFORE snapshots written by a live migration script. They are
|
|
269
|
+
# the recovery record for one machine's run, not repo content — the durable
|
|
270
|
+
# audit trail is the `metadata.migrations` stamp on the row itself.
|
|
271
|
+
.matrx-migrations/
|
|
272
|
+
|
|
273
|
+
# Trial Bench records written on THIS machine — the trial's JSON record, its §8
|
|
274
|
+
# report and the index that finds them (aidream/services/masterworks/bench/index.py,
|
|
275
|
+
# and the runs a product-started trial writes beside it). They are never repo
|
|
276
|
+
# content: a record carries every arm's full text INCLUDING the expert's ground
|
|
277
|
+
# truth, which is material deliberately withheld from the Rulebook, and a trial
|
|
278
|
+
# that matters is published deliberately under common-docs/projects/<its trial>/.
|
|
279
|
+
# Untracked-but-not-ignored meant one `git add -A` away from committing an
|
|
280
|
+
# expert's withheld work.
|
|
281
|
+
.matrx/bench/
|
|
282
|
+
|
|
283
|
+
# macOS Finder metadata
|
|
284
|
+
.DS_Store
|
|
285
|
+
**/.DS_Store
|
|
286
|
+
|
|
287
|
+
# Environment files
|
|
288
|
+
.env
|
|
289
|
+
.env.*
|
|
290
|
+
*.env
|
|
291
|
+
*.env.*
|
|
292
|
+
|
|
293
|
+
# Keep safe templates trackable
|
|
294
|
+
!.env.example
|
|
295
|
+
!.env.sample
|
|
296
|
+
!.env.template
|
|
297
|
+
|
|
298
|
+
# Never commit local OAuth client/token artifacts
|
|
299
|
+
credentials.json
|
|
300
|
+
token*.pickle
|
|
301
|
+
token*.json
|
|
302
|
+
tests_trials/rag_tests/kg_export_output/
|
|
303
|
+
|
|
304
|
+
# Pooler-contamination watch output (machine-local evidence, not source)
|
|
305
|
+
db/evidence/
|
|
306
|
+
|
|
307
|
+
# Pooler contamination evidence — machine-local forensic capture, not source
|
|
308
|
+
db/evidence/
|
|
309
|
+
db/mirror/.env.mirror
|
|
310
|
+
supabase/.temp/
|
|
311
|
+
**/supabase/.temp/
|
|
312
|
+
# Packed npm artifacts. Kept locally for a one-time bootstrap publish; never
|
|
313
|
+
# committed (they are large binaries regenerable with `pnpm pack`).
|
|
314
|
+
apps/shared/*/*.tgz
|
|
315
|
+
|
|
316
|
+
# Guard forcing-function scratch packages. These tests plant real files inside
|
|
317
|
+
# the real tree the guard scans (a temp dir would prove nothing) and delete
|
|
318
|
+
# them in teardown — ignoring them keeps the auto-commit tooling from
|
|
319
|
+
# capturing one mid-run.
|
|
320
|
+
_kind_boundary_scratch*/
|
|
321
|
+
_kind_marker_law_scratch*/
|
|
322
|
+
|
|
323
|
+
# packed npm tarballs are build output, never source (doctrine: typescript-package-standard)
|
|
324
|
+
*.tgz
|
|
325
|
+
|
|
326
|
+
# Peers' kit scratch witnesses. A `.kit-<name>-witness.XXXXXX/` directory is a
|
|
327
|
+
# full COPY of kit/src planted inside the packages tree — three of them held a
|
|
328
|
+
# duplicate `format.ts` on 2026-09-12 — and it sits in the `check:package-twins`
|
|
329
|
+
# scan ROOT. `git ls-files` only reaches TRACKED files, so the guard never saw
|
|
330
|
+
# them; the risk was a broad `git add` committing three formatter twins in one
|
|
331
|
+
# stroke, which is the exact class that guard exists to stop. Ignored, never
|
|
332
|
+
# deleted: they are another agent's evidence.
|
|
333
|
+
apps/shared/.kit-*-witness.*/
|
|
334
|
+
|
|
335
|
+
# Agent worktrees. Extra checkouts of this same repo, never product source.
|
|
336
|
+
# They live at .wt/<slug> (disk-groom). Committing the folder would add a
|
|
337
|
+
# second copy of the entire tree and a symlink into common-docs.
|
|
338
|
+
.wt/
|
|
339
|
+
.matrx/fixer-dispatch.json
|
|
340
|
+
.matrx/fixer-ledger.json
|
|
341
|
+
|
|
342
|
+
# Release streak ledger (scripts/release_repeats.py): per-machine state, never committed
|
|
343
|
+
.matrx/release-repeats.json
|
|
344
|
+
.matrx/release-repeats.json.tmp
|
|
345
|
+
.matrx/fixer-ledger.json
|
matrx_api-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: matrx-api
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for every AI Matrx server, generated from the language-neutral server contract (sister of @ai-matrx/api)
|
|
5
|
+
Author-email: Matrx <admin@aimatrx.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: api-client,matrx,ndjson,openapi
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Requires-Python: >=3.13
|
|
14
|
+
Requires-Dist: httpx>=0.27
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# matrx-api
|
|
18
|
+
|
|
19
|
+
The Python client of every AI Matrx server. Sister of the TypeScript `@ai-matrx/api`: both are
|
|
20
|
+
GENERATED from the same language-neutral server contract (`aidream/api-contract/`), so every
|
|
21
|
+
operation, deployment route, auth tier, org rule and stream kind agrees across languages.
|
|
22
|
+
|
|
23
|
+
Depends on `httpx` only. Never imports `aidream`, never reads env vars: the host injects
|
|
24
|
+
credentials, the organization and base URLs.
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from matrx_api import MatrxApi, UserCredential
|
|
28
|
+
from matrx_api.generated import files
|
|
29
|
+
|
|
30
|
+
async with MatrxApi(credentials=lambda: UserCredential(token()), organization_id=org_id,
|
|
31
|
+
base_urls={"aidream": "http://localhost:8000"}) as api:
|
|
32
|
+
meta = await files.get_file(api, path={"file_id": fid})
|
|
33
|
+
async for frame in await some_domain.some_ndjson_op(api, body={...}): # NDJSON -> parsed dicts
|
|
34
|
+
...
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Behaviours: credentials on every call (user / guest / api_key / service / scoped, re-read per call);
|
|
38
|
+
`X-Organization-Id` per the operation's org rule (required + missing -> `OrganizationContextError`
|
|
39
|
+
before the wire; exempt never sends one); unique `X-Request-Id`; GET/HEAD retry with backoff on network
|
|
40
|
+
failure, writes never; one `MatrxApiError(status, code, message)`; NDJSON/SSE/bytes streams as async
|
|
41
|
+
iterators (`*_or_json` operations return `JsonOrStream`).
|
|
42
|
+
|
|
43
|
+
## Regenerate
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
python packages/matrx-api/scripts/generate.py # after the contract changes
|
|
47
|
+
python packages/matrx-api/scripts/generate.py --check # exit 1 on drift (also run by the tests)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Writes `matrx_api/generated/<domain>.py` (one module per `x-matrx-domain`) and
|
|
51
|
+
`matrx_api/deployments.py` (`CONTRACT_SHA256`, default base URLs). RED (exit 1) on a missing/unknown
|
|
52
|
+
`x-matrx-*` tag, an operation no deployment serves, or a domain-module collision. Never edit generated files.
|
|
53
|
+
|
|
54
|
+
## Test
|
|
55
|
+
|
|
56
|
+
`uv run pytest packages/matrx-api/tests`
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# matrx-api
|
|
2
|
+
|
|
3
|
+
The Python client of every AI Matrx server. Sister of the TypeScript `@ai-matrx/api`: both are
|
|
4
|
+
GENERATED from the same language-neutral server contract (`aidream/api-contract/`), so every
|
|
5
|
+
operation, deployment route, auth tier, org rule and stream kind agrees across languages.
|
|
6
|
+
|
|
7
|
+
Depends on `httpx` only. Never imports `aidream`, never reads env vars: the host injects
|
|
8
|
+
credentials, the organization and base URLs.
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
from matrx_api import MatrxApi, UserCredential
|
|
12
|
+
from matrx_api.generated import files
|
|
13
|
+
|
|
14
|
+
async with MatrxApi(credentials=lambda: UserCredential(token()), organization_id=org_id,
|
|
15
|
+
base_urls={"aidream": "http://localhost:8000"}) as api:
|
|
16
|
+
meta = await files.get_file(api, path={"file_id": fid})
|
|
17
|
+
async for frame in await some_domain.some_ndjson_op(api, body={...}): # NDJSON -> parsed dicts
|
|
18
|
+
...
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Behaviours: credentials on every call (user / guest / api_key / service / scoped, re-read per call);
|
|
22
|
+
`X-Organization-Id` per the operation's org rule (required + missing -> `OrganizationContextError`
|
|
23
|
+
before the wire; exempt never sends one); unique `X-Request-Id`; GET/HEAD retry with backoff on network
|
|
24
|
+
failure, writes never; one `MatrxApiError(status, code, message)`; NDJSON/SSE/bytes streams as async
|
|
25
|
+
iterators (`*_or_json` operations return `JsonOrStream`).
|
|
26
|
+
|
|
27
|
+
## Regenerate
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
python packages/matrx-api/scripts/generate.py # after the contract changes
|
|
31
|
+
python packages/matrx-api/scripts/generate.py --check # exit 1 on drift (also run by the tests)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Writes `matrx_api/generated/<domain>.py` (one module per `x-matrx-domain`) and
|
|
35
|
+
`matrx_api/deployments.py` (`CONTRACT_SHA256`, default base URLs). RED (exit 1) on a missing/unknown
|
|
36
|
+
`x-matrx-*` tag, an operation no deployment serves, or a domain-module collision. Never edit generated files.
|
|
37
|
+
|
|
38
|
+
## Test
|
|
39
|
+
|
|
40
|
+
`uv run pytest packages/matrx-api/tests`
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""matrx-api: the Python client of every AI Matrx server, generated from the server contract."""
|
|
2
|
+
|
|
3
|
+
from .client import (
|
|
4
|
+
ApiStream,
|
|
5
|
+
CallOptions,
|
|
6
|
+
JsonOrStream,
|
|
7
|
+
MatrxApi,
|
|
8
|
+
Multipart,
|
|
9
|
+
OperationDescriptor,
|
|
10
|
+
RequestInfo,
|
|
11
|
+
)
|
|
12
|
+
from .credentials import (
|
|
13
|
+
ApiKeyCredential,
|
|
14
|
+
GuestCredential,
|
|
15
|
+
MATRX_HEADERS,
|
|
16
|
+
ScopedCredential,
|
|
17
|
+
ServiceCredential,
|
|
18
|
+
UserCredential,
|
|
19
|
+
credential_to_headers,
|
|
20
|
+
)
|
|
21
|
+
from .deployments import CONTRACT_SHA256, DEPLOYMENTS, DOMAINS
|
|
22
|
+
from .errors import MatrxApiError, OrganizationContextError
|
|
23
|
+
from .streams import NdjsonFramer, SseFrame, SseFramer
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"ApiKeyCredential", "ApiStream", "CONTRACT_SHA256", "CallOptions", "DEPLOYMENTS", "DOMAINS",
|
|
27
|
+
"GuestCredential", "JsonOrStream", "MATRX_HEADERS", "MatrxApi", "MatrxApiError", "Multipart",
|
|
28
|
+
"NdjsonFramer", "OperationDescriptor", "OrganizationContextError", "RequestInfo",
|
|
29
|
+
"ScopedCredential", "ServiceCredential", "SseFrame", "SseFramer", "UserCredential",
|
|
30
|
+
"credential_to_headers",
|
|
31
|
+
]
|