tai42-contract 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.
- tai42_contract-0.1.0/LICENSE +202 -0
- tai42_contract-0.1.0/MANIFEST.in +1 -0
- tai42_contract-0.1.0/NOTICE +5 -0
- tai42_contract-0.1.0/PKG-INFO +99 -0
- tai42_contract-0.1.0/README.md +66 -0
- tai42_contract-0.1.0/pyproject.toml +88 -0
- tai42_contract-0.1.0/setup.cfg +4 -0
- tai42_contract-0.1.0/src/tai42_contract/__init__.py +36 -0
- tai42_contract-0.1.0/src/tai42_contract/access_control/__init__.py +50 -0
- tai42_contract-0.1.0/src/tai42_contract/access_control/context.py +40 -0
- tai42_contract-0.1.0/src/tai42_contract/access_control/identity.py +166 -0
- tai42_contract-0.1.0/src/tai42_contract/access_control/models.py +119 -0
- tai42_contract-0.1.0/src/tai42_contract/access_control/policy.py +39 -0
- tai42_contract-0.1.0/src/tai42_contract/access_control/registry.py +67 -0
- tai42_contract-0.1.0/src/tai42_contract/access_control/verifier.py +26 -0
- tai42_contract-0.1.0/src/tai42_contract/accounts/__init__.py +36 -0
- tai42_contract-0.1.0/src/tai42_contract/accounts/models.py +109 -0
- tai42_contract-0.1.0/src/tai42_contract/accounts/provider.py +105 -0
- tai42_contract-0.1.0/src/tai42_contract/accounts/registry.py +83 -0
- tai42_contract-0.1.0/src/tai42_contract/agent/__init__.py +42 -0
- tai42_contract-0.1.0/src/tai42_contract/agent/base.py +242 -0
- tai42_contract-0.1.0/src/tai42_contract/agent/events.py +110 -0
- tai42_contract-0.1.0/src/tai42_contract/app/__init__.py +134 -0
- tai42_contract-0.1.0/src/tai42_contract/app/facets.py +398 -0
- tai42_contract-0.1.0/src/tai42_contract/app/handle.py +44 -0
- tai42_contract-0.1.0/src/tai42_contract/backend/__init__.py +8 -0
- tai42_contract-0.1.0/src/tai42_contract/backend/base.py +24 -0
- tai42_contract-0.1.0/src/tai42_contract/backend/callback.py +8 -0
- tai42_contract-0.1.0/src/tai42_contract/backup/__init__.py +15 -0
- tai42_contract-0.1.0/src/tai42_contract/backup/models.py +26 -0
- tai42_contract-0.1.0/src/tai42_contract/channels/__init__.py +172 -0
- tai42_contract-0.1.0/src/tai42_contract/clients/__init__.py +33 -0
- tai42_contract-0.1.0/src/tai42_contract/config/__init__.py +10 -0
- tai42_contract-0.1.0/src/tai42_contract/config/manager.py +128 -0
- tai42_contract-0.1.0/src/tai42_contract/config/settings.py +33 -0
- tai42_contract-0.1.0/src/tai42_contract/connectors/__init__.py +97 -0
- tai42_contract-0.1.0/src/tai42_contract/connectors/errors.py +23 -0
- tai42_contract-0.1.0/src/tai42_contract/connectors/models.py +316 -0
- tai42_contract-0.1.0/src/tai42_contract/connectors/probe.py +25 -0
- tai42_contract-0.1.0/src/tai42_contract/connectors/providers.py +215 -0
- tai42_contract-0.1.0/src/tai42_contract/connectors/service.py +165 -0
- tai42_contract-0.1.0/src/tai42_contract/connectors/store.py +101 -0
- tai42_contract-0.1.0/src/tai42_contract/errors/__init__.py +14 -0
- tai42_contract-0.1.0/src/tai42_contract/extensions/__init__.py +131 -0
- tai42_contract-0.1.0/src/tai42_contract/extensions/kinds.py +74 -0
- tai42_contract-0.1.0/src/tai42_contract/hooks/__init__.py +9 -0
- tai42_contract-0.1.0/src/tai42_contract/hooks/manager.py +35 -0
- tai42_contract-0.1.0/src/tai42_contract/hooks/models.py +37 -0
- tai42_contract-0.1.0/src/tai42_contract/interactions/__init__.py +39 -0
- tai42_contract-0.1.0/src/tai42_contract/interactions/asker.py +106 -0
- tai42_contract-0.1.0/src/tai42_contract/interactions/models.py +227 -0
- tai42_contract-0.1.0/src/tai42_contract/manifest/__init__.py +405 -0
- tai42_contract-0.1.0/src/tai42_contract/monitoring/__init__.py +59 -0
- tai42_contract-0.1.0/src/tai42_contract/monitoring/errors.py +25 -0
- tai42_contract-0.1.0/src/tai42_contract/monitoring/models.py +324 -0
- tai42_contract-0.1.0/src/tai42_contract/monitoring/monitoring.py +36 -0
- tai42_contract-0.1.0/src/tai42_contract/monitoring/reader.py +101 -0
- tai42_contract-0.1.0/src/tai42_contract/monitoring/writer.py +200 -0
- tai42_contract-0.1.0/src/tai42_contract/plugins/__init__.py +520 -0
- tai42_contract-0.1.0/src/tai42_contract/presets/__init__.py +148 -0
- tai42_contract-0.1.0/src/tai42_contract/presets/errors.py +51 -0
- tai42_contract-0.1.0/src/tai42_contract/presets/models.py +69 -0
- tai42_contract-0.1.0/src/tai42_contract/py.typed +0 -0
- tai42_contract-0.1.0/src/tai42_contract/storage/__init__.py +117 -0
- tai42_contract-0.1.0/src/tai42_contract/sub_mcp/__init__.py +53 -0
- tai42_contract-0.1.0/src/tai42_contract/template/__init__.py +29 -0
- tai42_contract-0.1.0/src/tai42_contract/tools/__init__.py +78 -0
- tai42_contract-0.1.0/src/tai42_contract/transport/__init__.py +24 -0
- tai42_contract-0.1.0/src/tai42_contract/versioning/__init__.py +119 -0
- tai42_contract-0.1.0/src/tai42_contract/versioning/errors.py +45 -0
- tai42_contract-0.1.0/src/tai42_contract/versioning/models.py +51 -0
- tai42_contract-0.1.0/src/tai42_contract/webhooks/__init__.py +62 -0
- tai42_contract-0.1.0/src/tai42_contract.egg-info/PKG-INFO +99 -0
- tai42_contract-0.1.0/src/tai42_contract.egg-info/SOURCES.txt +75 -0
- tai42_contract-0.1.0/src/tai42_contract.egg-info/dependency_links.txt +1 -0
- tai42_contract-0.1.0/src/tai42_contract.egg-info/requires.txt +11 -0
- tai42_contract-0.1.0/src/tai42_contract.egg-info/top_level.txt +1 -0
|
@@ -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 @@
|
|
|
1
|
+
prune tests
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tai42-contract
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pure interface contracts (protocols, ABCs, models) for the TAI ecosystem. No logic; pydantic-only at runtime.
|
|
5
|
+
Author-email: tai42 <oss@tai42.ai>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://tai42.ai
|
|
8
|
+
Project-URL: Repository, https://github.com/tai42ai/tai-contract
|
|
9
|
+
Project-URL: Issues, https://github.com/tai42ai/tai-contract/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/tai42ai/tai-contract/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: protocol,contract,interface,typing,mcp,agents
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.13
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
License-File: NOTICE
|
|
22
|
+
Requires-Dist: pydantic>=2.12
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-cov>=5; extra == "dev"
|
|
26
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
27
|
+
Requires-Dist: pyright>=1.1.389; extra == "dev"
|
|
28
|
+
Requires-Dist: fastmcp>=3; extra == "dev"
|
|
29
|
+
Requires-Dist: langchain-core>=1; extra == "dev"
|
|
30
|
+
Requires-Dist: starlette>=0.40; extra == "dev"
|
|
31
|
+
Requires-Dist: mcp>=1; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# tai42-contract
|
|
35
|
+
|
|
36
|
+
[](https://github.com/tai42ai/tai-contract/actions/workflows/ci.yml)
|
|
37
|
+
[](LICENSE)
|
|
38
|
+
|
|
39
|
+
Pure interface contracts for the TAI ecosystem: the protocols, ABCs, pydantic
|
|
40
|
+
models, and enums every other package builds against. At runtime this package
|
|
41
|
+
imports nothing but `pydantic`, and its behaviour is limited to a narrow
|
|
42
|
+
whitelisted surface — the `tai42_app` forwarding handle, model-level
|
|
43
|
+
validators/normalizers, the storage path guard, and `Agent`'s default
|
|
44
|
+
`astream`/terminal-drain; everything else is a pydantic model, Protocol, ABC, or
|
|
45
|
+
enum. Vendor types (fastmcp, langchain, starlette, mcp) appear only inside
|
|
46
|
+
`TYPE_CHECKING` blocks, so they are never loaded when the code runs.
|
|
47
|
+
|
|
48
|
+
## Position in the ecosystem
|
|
49
|
+
|
|
50
|
+
TAI is an open-source runtime for MCP tools, agents, and workflows — the server
|
|
51
|
+
that hosts a capability and supplies the operational layer around it (manifest
|
|
52
|
+
loading, access control, OAuth connectors, background execution, monitoring,
|
|
53
|
+
storage, and human-in-the-loop steps). Everything plugs in against the
|
|
54
|
+
interfaces this package defines.
|
|
55
|
+
|
|
56
|
+
Three packages; each depends only on the ones to its left:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
tai42-contract <-- tai42-kit <-- tai42-skeleton
|
|
60
|
+
(interfaces) (helpers) (the server)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`tai42-contract` is the leaf: it depends on no other tai-* package, so anything —
|
|
64
|
+
the skeleton, a plugin, a helper — can import it without pulling in an
|
|
65
|
+
implementation.
|
|
66
|
+
|
|
67
|
+
## Install
|
|
68
|
+
|
|
69
|
+
Requires **Python 3.13+**. Nothing is on PyPI yet, so install from source —
|
|
70
|
+
clone this repo alongside your `tai-skeleton` checkout and add it as an editable
|
|
71
|
+
dependency of the environment that runs the server. Usually pulled in
|
|
72
|
+
transitively via `tai42-kit` / `tai42-skeleton`, but it installs directly too:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/tai42ai/tai-contract
|
|
76
|
+
cd tai-skeleton # or your own app checkout
|
|
77
|
+
uv add --editable ../tai-contract # once published: uv add tai42-contract
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Development
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
uv sync --extra dev # pydantic + tooling + vendor libs (for pyright)
|
|
84
|
+
uv run ruff check .
|
|
85
|
+
uv run pyright
|
|
86
|
+
uv run pytest # self-contained contract tests
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Documentation
|
|
90
|
+
|
|
91
|
+
The whole platform — concepts, guides, and the generated reference — lives in
|
|
92
|
+
the unified documentation site:
|
|
93
|
+
|
|
94
|
+
- Layering & the contract/kit/skeleton split: https://tai42.ai/concepts/layering
|
|
95
|
+
- Python SDK reference (this package's public API): https://tai42.ai/reference/python-sdk
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
Apache-2.0. See `LICENSE` and `NOTICE`.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# tai42-contract
|
|
2
|
+
|
|
3
|
+
[](https://github.com/tai42ai/tai-contract/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
Pure interface contracts for the TAI ecosystem: the protocols, ABCs, pydantic
|
|
7
|
+
models, and enums every other package builds against. At runtime this package
|
|
8
|
+
imports nothing but `pydantic`, and its behaviour is limited to a narrow
|
|
9
|
+
whitelisted surface — the `tai42_app` forwarding handle, model-level
|
|
10
|
+
validators/normalizers, the storage path guard, and `Agent`'s default
|
|
11
|
+
`astream`/terminal-drain; everything else is a pydantic model, Protocol, ABC, or
|
|
12
|
+
enum. Vendor types (fastmcp, langchain, starlette, mcp) appear only inside
|
|
13
|
+
`TYPE_CHECKING` blocks, so they are never loaded when the code runs.
|
|
14
|
+
|
|
15
|
+
## Position in the ecosystem
|
|
16
|
+
|
|
17
|
+
TAI is an open-source runtime for MCP tools, agents, and workflows — the server
|
|
18
|
+
that hosts a capability and supplies the operational layer around it (manifest
|
|
19
|
+
loading, access control, OAuth connectors, background execution, monitoring,
|
|
20
|
+
storage, and human-in-the-loop steps). Everything plugs in against the
|
|
21
|
+
interfaces this package defines.
|
|
22
|
+
|
|
23
|
+
Three packages; each depends only on the ones to its left:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
tai42-contract <-- tai42-kit <-- tai42-skeleton
|
|
27
|
+
(interfaces) (helpers) (the server)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`tai42-contract` is the leaf: it depends on no other tai-* package, so anything —
|
|
31
|
+
the skeleton, a plugin, a helper — can import it without pulling in an
|
|
32
|
+
implementation.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
Requires **Python 3.13+**. Nothing is on PyPI yet, so install from source —
|
|
37
|
+
clone this repo alongside your `tai-skeleton` checkout and add it as an editable
|
|
38
|
+
dependency of the environment that runs the server. Usually pulled in
|
|
39
|
+
transitively via `tai42-kit` / `tai42-skeleton`, but it installs directly too:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/tai42ai/tai-contract
|
|
43
|
+
cd tai-skeleton # or your own app checkout
|
|
44
|
+
uv add --editable ../tai-contract # once published: uv add tai42-contract
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Development
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
uv sync --extra dev # pydantic + tooling + vendor libs (for pyright)
|
|
51
|
+
uv run ruff check .
|
|
52
|
+
uv run pyright
|
|
53
|
+
uv run pytest # self-contained contract tests
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Documentation
|
|
57
|
+
|
|
58
|
+
The whole platform — concepts, guides, and the generated reference — lives in
|
|
59
|
+
the unified documentation site:
|
|
60
|
+
|
|
61
|
+
- Layering & the contract/kit/skeleton split: https://tai42.ai/concepts/layering
|
|
62
|
+
- Python SDK reference (this package's public API): https://tai42.ai/reference/python-sdk
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
Apache-2.0. See `LICENSE` and `NOTICE`.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tai42-contract"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Pure interface contracts (protocols, ABCs, models) for the TAI ecosystem. No logic; pydantic-only at runtime."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.13"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "tai42", email = "oss@tai42.ai" },
|
|
15
|
+
]
|
|
16
|
+
keywords = ["protocol", "contract", "interface", "typing", "mcp", "agents"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 4 - Beta",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
"Typing :: Typed",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"pydantic>=2.12",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://tai42.ai"
|
|
31
|
+
Repository = "https://github.com/tai42ai/tai-contract"
|
|
32
|
+
Issues = "https://github.com/tai42ai/tai-contract/issues"
|
|
33
|
+
Changelog = "https://github.com/tai42ai/tai-contract/blob/main/CHANGELOG.md"
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
# Public dev/test tooling — a clone needs nothing private to lint, type-check,
|
|
37
|
+
# and run the self-contained contract tests. The vendor libs are here so pyright
|
|
38
|
+
# can resolve the TYPE_CHECKING-only annotations; they are never runtime deps.
|
|
39
|
+
dev = [
|
|
40
|
+
"pytest>=8",
|
|
41
|
+
"pytest-cov>=5",
|
|
42
|
+
"ruff>=0.6",
|
|
43
|
+
"pyright>=1.1.389",
|
|
44
|
+
"fastmcp>=3",
|
|
45
|
+
"langchain-core>=1",
|
|
46
|
+
"starlette>=0.40",
|
|
47
|
+
"mcp>=1",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools]
|
|
51
|
+
package-dir = { "" = "src" }
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.packages.find]
|
|
54
|
+
where = ["src"]
|
|
55
|
+
include = ["tai42_contract*"]
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.package-data]
|
|
58
|
+
tai42_contract = ["py.typed"]
|
|
59
|
+
|
|
60
|
+
[tool.uv]
|
|
61
|
+
cache-keys = [{ file = "pyproject.toml" }]
|
|
62
|
+
|
|
63
|
+
[tool.ruff]
|
|
64
|
+
src = ["src"]
|
|
65
|
+
target-version = "py313"
|
|
66
|
+
line-length = 120
|
|
67
|
+
|
|
68
|
+
[tool.ruff.lint]
|
|
69
|
+
select = ["E", "W", "F", "I", "UP", "B", "C4", "SIM", "PIE", "PT", "RUF", "TID"]
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
|
|
72
|
+
"tai42_kit".msg = "tai42-contract is the leaf: it never imports tai42-kit."
|
|
73
|
+
"tai42_skeleton".msg = "tai42-contract is the leaf: it never imports tai42-skeleton."
|
|
74
|
+
|
|
75
|
+
[tool.pytest.ini_options]
|
|
76
|
+
xfail_strict = true
|
|
77
|
+
testpaths = ["tests"]
|
|
78
|
+
|
|
79
|
+
[tool.coverage.run]
|
|
80
|
+
source = ["tai42_contract"]
|
|
81
|
+
|
|
82
|
+
[tool.coverage.report]
|
|
83
|
+
fail_under = 97
|
|
84
|
+
|
|
85
|
+
[tool.pyright]
|
|
86
|
+
include = ["src", "tests"]
|
|
87
|
+
pythonVersion = "3.13"
|
|
88
|
+
typeCheckingMode = "strict"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""tai42-contract — pure interface contracts for the TAI ecosystem.
|
|
2
|
+
|
|
3
|
+
Protocols, ABCs, and pydantic models only. No logic. At runtime this package
|
|
4
|
+
imports nothing but ``pydantic``; vendor types are ``TYPE_CHECKING``-only.
|
|
5
|
+
|
|
6
|
+
The primary entry points are re-exported here: the assembled ``TaiApp`` facade
|
|
7
|
+
and its runtime forwarding handle ``tai42_app``, plus the names most consumers
|
|
8
|
+
need (``Agent``, ``Manifest``, ``ToolInfo``, ``Storage``, ``Backend``, and the
|
|
9
|
+
shared exception types). Everything else stays in its subpackage.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from importlib.metadata import version
|
|
15
|
+
|
|
16
|
+
from tai42_contract.agent import Agent
|
|
17
|
+
from tai42_contract.app import TaiApp, tai42_app
|
|
18
|
+
from tai42_contract.backend import Backend
|
|
19
|
+
from tai42_contract.errors import ClientDisconnectedError
|
|
20
|
+
from tai42_contract.manifest import Manifest
|
|
21
|
+
from tai42_contract.storage import Storage
|
|
22
|
+
from tai42_contract.tools import ToolInfo
|
|
23
|
+
|
|
24
|
+
__version__ = version("tai42-contract")
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"Agent",
|
|
28
|
+
"Backend",
|
|
29
|
+
"ClientDisconnectedError",
|
|
30
|
+
"Manifest",
|
|
31
|
+
"Storage",
|
|
32
|
+
"TaiApp",
|
|
33
|
+
"ToolInfo",
|
|
34
|
+
"__version__",
|
|
35
|
+
"tai42_app",
|
|
36
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Access-control contract: identity, policy/context models, and the ``Verifier``
|
|
2
|
+
/ ``PolicyEnforcer`` protocols."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from tai42_contract.access_control.context import (
|
|
7
|
+
get_current_user_id,
|
|
8
|
+
reset_request_user_id,
|
|
9
|
+
set_request_user_id,
|
|
10
|
+
)
|
|
11
|
+
from tai42_contract.access_control.identity import (
|
|
12
|
+
OWNER_USER_ID_CLAIM,
|
|
13
|
+
ApiKeyIdentityProvider,
|
|
14
|
+
AuthIdentity,
|
|
15
|
+
IdentityProvider,
|
|
16
|
+
IdentityProviderSettings,
|
|
17
|
+
)
|
|
18
|
+
from tai42_contract.access_control.models import (
|
|
19
|
+
AccessPolicy,
|
|
20
|
+
IdentityRecord,
|
|
21
|
+
JqAuthContext,
|
|
22
|
+
RoleDefinition,
|
|
23
|
+
)
|
|
24
|
+
from tai42_contract.access_control.policy import PolicyEnforcer
|
|
25
|
+
from tai42_contract.access_control.registry import (
|
|
26
|
+
get_identity_provider_factory,
|
|
27
|
+
register_identity_provider,
|
|
28
|
+
reset_registry,
|
|
29
|
+
)
|
|
30
|
+
from tai42_contract.access_control.verifier import Verifier
|
|
31
|
+
|
|
32
|
+
__all__ = [
|
|
33
|
+
"OWNER_USER_ID_CLAIM",
|
|
34
|
+
"AccessPolicy",
|
|
35
|
+
"ApiKeyIdentityProvider",
|
|
36
|
+
"AuthIdentity",
|
|
37
|
+
"IdentityProvider",
|
|
38
|
+
"IdentityProviderSettings",
|
|
39
|
+
"IdentityRecord",
|
|
40
|
+
"JqAuthContext",
|
|
41
|
+
"PolicyEnforcer",
|
|
42
|
+
"RoleDefinition",
|
|
43
|
+
"Verifier",
|
|
44
|
+
"get_current_user_id",
|
|
45
|
+
"get_identity_provider_factory",
|
|
46
|
+
"register_identity_provider",
|
|
47
|
+
"reset_registry",
|
|
48
|
+
"reset_request_user_id",
|
|
49
|
+
"set_request_user_id",
|
|
50
|
+
]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Request-scoped caller-identity context.
|
|
2
|
+
|
|
3
|
+
The host binds the calling user's id into a context variable for the duration of
|
|
4
|
+
each request; any plugin reads it back through :func:`get_current_user_id`
|
|
5
|
+
without depending on the host. The value defaults to ``None`` — an anonymous
|
|
6
|
+
caller, or any code path running outside a bound request.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from contextvars import ContextVar, Token
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"get_current_user_id",
|
|
15
|
+
"reset_request_user_id",
|
|
16
|
+
"set_request_user_id",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
_current_user_id: ContextVar[str | None] = ContextVar("tai42_current_user_id", default=None)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def get_current_user_id() -> str | None:
|
|
23
|
+
"""Return the calling user's id for the current request, or ``None`` when no
|
|
24
|
+
caller is bound — an anonymous request, or code running outside a request."""
|
|
25
|
+
return _current_user_id.get()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def set_request_user_id(user_id: str | None) -> Token[str | None]:
|
|
29
|
+
"""Bind ``user_id`` as the current context's caller and return the reset token.
|
|
30
|
+
|
|
31
|
+
The host calls this once per request; pass the returned token to
|
|
32
|
+
:func:`reset_request_user_id` to restore the previous value.
|
|
33
|
+
"""
|
|
34
|
+
return _current_user_id.set(user_id)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def reset_request_user_id(token: Token[str | None]) -> None:
|
|
38
|
+
"""Restore the caller id to the value captured in ``token`` by the matching
|
|
39
|
+
:func:`set_request_user_id` call."""
|
|
40
|
+
_current_user_id.reset(token)
|