nemo-agent-toolkit-tenuo 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ /target/
2
+ **/*.rs.bk
3
+ .DS_Store
4
+
5
+ .env
6
+ .env.*
7
+ *.pem
8
+ *.key
9
+ *.p8
10
+ credentials.json
11
+ results/
12
+
13
+ # Local implementation spec. Not committed.
14
+ docs/spec.md
15
+
16
+ /.cache/
17
+ /.venv/
18
+ __pycache__/
19
+ *.py[cod]
20
+ .pytest_cache/
@@ -0,0 +1,187 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as defined by the copyright owner, any
48
+ work of authorship, including the original version of the Work and
49
+ any modifications or additions to that Work or Derivative Works of
50
+ the Work, submitted to the Licensor for inclusion in the Work by the
51
+ copyright owner or by an individual or Legal Entity authorized to
52
+ submit on behalf of the copyright owner. For the purposes of this
53
+ definition, "submitted" means any form of electronic, verbal, or
54
+ written communication sent to the Licensor or its representatives,
55
+ including but not limited to communication on electronic mailing lists,
56
+ source code control systems, and issue tracking systems that are managed
57
+ by, or on behalf of, the Licensor for the purpose of discussing and
58
+ improving the Work, but excluding communication that is conspicuously
59
+ marked or designated in writing by the copyright owner as "Not a
60
+ Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
63
+ whom a Contribution has been received by the Licensor and included
64
+ within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by the combined work of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a cross-claim
83
+ or counterclaim in a lawsuit) alleging that the Work or any
84
+ Contribution embodied within the Work constitutes direct or contributory
85
+ patent infringement, then any patent licenses granted to You under
86
+ this License for that Work shall terminate as of the date such
87
+ litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, You must include a readable copy of the
108
+ attribution notices contained within such NOTICE file, in
109
+ at least one of the following places: within a NOTICE text
110
+ file distributed as part of the Derivative Works; within
111
+ the Source form or documentation, if provided along with the
112
+ Derivative Works; or, within a display generated by the
113
+ Derivative Works, if and wherever such third-party notices
114
+ normally appear. The contents of the NOTICE file are for
115
+ informational purposes only and do not modify the License.
116
+ You may add Your own attribution notices within Derivative
117
+ Works that You distribute, alongside or as an addendum to
118
+ the NOTICE text from the Work, provided that such additional
119
+ attribution notices cannot be construed as modifying the License.
120
+
121
+ You may add Your own license statement for Your modifications and
122
+ may provide additional grant of rights to use, copy, modify, merge,
123
+ publish, distribute, sublicense, and/or sell copies of the
124
+ Derivative Works, and to permit persons to whom the Derivative Works
125
+ are furnished to do so, subject to Your terms.
126
+
127
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
128
+ any Contribution intentionally submitted for inclusion in the Work
129
+ by You to the Licensor shall be under the terms and conditions of
130
+ this License, without any additional terms or conditions.
131
+ Notwithstanding the above, nothing herein shall supersede or modify
132
+ the terms of any separate license agreement you may have executed
133
+ with Licensor regarding such Contributions.
134
+
135
+ 6. Trademarks. This License does not grant permission to use the trade
136
+ names, trademarks, service marks, or product names of the Licensor,
137
+ except as required for reasonable and customary use in describing the
138
+ origin of the Work and reproducing the content of the NOTICE file.
139
+
140
+ 7. Disclaimer of Warranty. Unless required by applicable law or
141
+ agreed to in writing, Licensor provides the Work (and each
142
+ Contributor provides its Contributions) on an "AS IS" BASIS,
143
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
144
+ implied, including, without limitation, any warranties or conditions
145
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
146
+ PARTICULAR PURPOSE. You are solely responsible for determining the
147
+ appropriateness of using or reproducing the Work and assume any
148
+ risks associated with Your exercise of permissions under this License.
149
+
150
+ 8. Limitation of Liability. In no event and under no legal theory,
151
+ whether in tort (including negligence), contract, or otherwise,
152
+ unless required by applicable law (such as deliberate and grossly
153
+ negligent acts) or agreed to in writing, shall any Contributor be
154
+ liable to You for damages, including any direct, indirect, special,
155
+ incidental, or exemplary damages of any character arising as a
156
+ result of this License or out of the use or inability to use the
157
+ Work (including but not limited to damages for loss of goodwill,
158
+ work stoppage, computer failure or malfunction, or all other
159
+ commercial damages or losses), even if such Contributor has been
160
+ advised of the possibility of such damages.
161
+
162
+ 9. Accepting Warranty or Additional Liability. While redistributing
163
+ the Work or Derivative Works thereof, You may offer, and charge a
164
+ fee for, acceptance of support, warranty, indemnity, or other
165
+ liability obligations and/or rights consistent with this License.
166
+ However, in accepting such obligations, You may offer such obligations
167
+ only on Your own behalf and on Your sole responsibility, not on
168
+ behalf of any other Contributor, and only if You agree to indemnify,
169
+ defend, and hold each Contributor harmless for any liability
170
+ incurred by, or claims asserted against, such Contributor by reason
171
+ of your accepting any such warranty or additional liability.
172
+
173
+ END OF TERMS AND CONDITIONS
174
+
175
+ Copyright 2025-2026 Tenuo Contributors
176
+
177
+ Licensed under the Apache License, Version 2.0 (the "License");
178
+ you may not use this file except in compliance with the License.
179
+ You may obtain a copy of the License at
180
+
181
+ http://www.apache.org/licenses/LICENSE-2.0
182
+
183
+ Unless required by applicable law or agreed to in writing, software
184
+ distributed under the License is distributed on an "AS IS" BASIS,
185
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
186
+ See the License for the specific language governing permissions and
187
+ limitations under the License.
@@ -0,0 +1,118 @@
1
+ Metadata-Version: 2.5
2
+ Name: nemo-agent-toolkit-tenuo
3
+ Version: 0.1.0
4
+ Summary: Task-scoped Tenuo authorization for NVIDIA NeMo Agent Toolkit
5
+ Project-URL: Documentation, https://github.com/tenuo-ai/tenuo-openshell/tree/main/python/nemo-agent-toolkit-tenuo
6
+ Project-URL: Issues, https://github.com/tenuo-ai/tenuo-openshell/issues
7
+ Project-URL: Source, https://github.com/tenuo-ai/tenuo-openshell
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: agents,authorization,nemo-agent-toolkit,nvidia,security
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Security
18
+ Requires-Python: <3.14,>=3.11
19
+ Requires-Dist: nvidia-nat-core<1.9,>=1.8
20
+ Requires-Dist: packaging>=23
21
+ Requires-Dist: tenuo<0.4,>=0.3.2
22
+ Provides-Extra: test
23
+ Requires-Dist: nvidia-nat-test<1.9,>=1.8; extra == 'test'
24
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'test'
25
+ Requires-Dist: pytest>=8.0; extra == 'test'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # NVIDIA NeMo Agent Toolkit — Tenuo
29
+
30
+ Provider-owned Agent Toolkit middleware that checks a Tenuo warrant before a
31
+ function runs. Unauthorized calls stop before `call_next`, so protected
32
+ function code never receives them.
33
+
34
+ This package is the in-process Agent Toolkit integration. The OpenShell
35
+ supervisor middleware at the repository root is the independent enforcement
36
+ point for MCP traffic that leaves the sandbox. Use both: the plugin catches
37
+ calls early, with readable errors, and the middleware enforces at the network
38
+ boundary.
39
+
40
+ ## Install
41
+
42
+ Tagged releases publish the package to PyPI. To install from a checkout, run
43
+ this from the repository root in the same environment as Agent Toolkit 1.8:
44
+
45
+ ```bash
46
+ uv sync --locked --project python/nemo-agent-toolkit-tenuo --extra test
47
+ uv run --locked --project python/nemo-agent-toolkit-tenuo nat info components
48
+ ```
49
+
50
+ For an existing environment, an editable or regular local install also works:
51
+
52
+ ```bash
53
+ python -m pip install ./python/nemo-agent-toolkit-tenuo
54
+ ```
55
+
56
+ The package uses NVIDIA's third-party plugin convention:
57
+
58
+ | Surface | Value |
59
+ | --- | --- |
60
+ | Distribution | `nemo-agent-toolkit-tenuo` |
61
+ | Import | `nat.plugins.tenuo` |
62
+ | Entry point | `nat_tenuo` |
63
+ | Middleware `_type` | `tenuo` |
64
+
65
+ ## Bind task authority
66
+
67
+ Bind authority in application-controlled task scope. Do not accept a warrant
68
+ or holder key from model-generated function arguments.
69
+
70
+ ```python
71
+ from nat.plugins.tenuo import authority
72
+
73
+ with authority(warrant.bind(holder)):
74
+ result = await workflow.ainvoke(input)
75
+ ```
76
+
77
+ The binding follows Python context propagation, including async tasks created
78
+ inside the block. The middleware does not write MCP `_meta.tenuo`; use Tenuo's
79
+ `SecureMCPClient` when the same authority must cross an MCP boundary.
80
+
81
+ ## Configure middleware
82
+
83
+ ```yaml
84
+ middleware:
85
+ task_authorization:
86
+ _type: tenuo
87
+ trusted_roots:
88
+ - "<64 hex characters of a 32-byte issuer public key>"
89
+
90
+ functions:
91
+ read_logs:
92
+ _type: read_logs
93
+ middleware: [task_authorization]
94
+ ```
95
+
96
+ `trusted_roots` selects accepted issuers and cannot be empty. A denied call
97
+ raises `AuthorizationDenied`; a call needing a signed approval raises
98
+ `ApprovalRequired`, which subclasses it. The middleware is not final, so later
99
+ middleware continues after an allow.
100
+
101
+ ## Compatibility and verification
102
+
103
+ Tested with Python 3.11–3.13, `nvidia-nat-core` 1.8.x, and
104
+ Tenuo 0.3.x. Run its tests and distribution build with:
105
+
106
+ ```bash
107
+ uv run --locked --project python/nemo-agent-toolkit-tenuo --extra test \
108
+ pytest python/nemo-agent-toolkit-tenuo/tests -q
109
+ uv build --project python/nemo-agent-toolkit-tenuo
110
+ ```
111
+
112
+ See the repository [security policy](../../SECURITY.md) before reporting a
113
+ vulnerability and [release guide](../../docs/releasing.md) for the publication
114
+ gate.
115
+
116
+ ## License
117
+
118
+ Apache-2.0.
@@ -0,0 +1,91 @@
1
+ # NVIDIA NeMo Agent Toolkit — Tenuo
2
+
3
+ Provider-owned Agent Toolkit middleware that checks a Tenuo warrant before a
4
+ function runs. Unauthorized calls stop before `call_next`, so protected
5
+ function code never receives them.
6
+
7
+ This package is the in-process Agent Toolkit integration. The OpenShell
8
+ supervisor middleware at the repository root is the independent enforcement
9
+ point for MCP traffic that leaves the sandbox. Use both: the plugin catches
10
+ calls early, with readable errors, and the middleware enforces at the network
11
+ boundary.
12
+
13
+ ## Install
14
+
15
+ Tagged releases publish the package to PyPI. To install from a checkout, run
16
+ this from the repository root in the same environment as Agent Toolkit 1.8:
17
+
18
+ ```bash
19
+ uv sync --locked --project python/nemo-agent-toolkit-tenuo --extra test
20
+ uv run --locked --project python/nemo-agent-toolkit-tenuo nat info components
21
+ ```
22
+
23
+ For an existing environment, an editable or regular local install also works:
24
+
25
+ ```bash
26
+ python -m pip install ./python/nemo-agent-toolkit-tenuo
27
+ ```
28
+
29
+ The package uses NVIDIA's third-party plugin convention:
30
+
31
+ | Surface | Value |
32
+ | --- | --- |
33
+ | Distribution | `nemo-agent-toolkit-tenuo` |
34
+ | Import | `nat.plugins.tenuo` |
35
+ | Entry point | `nat_tenuo` |
36
+ | Middleware `_type` | `tenuo` |
37
+
38
+ ## Bind task authority
39
+
40
+ Bind authority in application-controlled task scope. Do not accept a warrant
41
+ or holder key from model-generated function arguments.
42
+
43
+ ```python
44
+ from nat.plugins.tenuo import authority
45
+
46
+ with authority(warrant.bind(holder)):
47
+ result = await workflow.ainvoke(input)
48
+ ```
49
+
50
+ The binding follows Python context propagation, including async tasks created
51
+ inside the block. The middleware does not write MCP `_meta.tenuo`; use Tenuo's
52
+ `SecureMCPClient` when the same authority must cross an MCP boundary.
53
+
54
+ ## Configure middleware
55
+
56
+ ```yaml
57
+ middleware:
58
+ task_authorization:
59
+ _type: tenuo
60
+ trusted_roots:
61
+ - "<64 hex characters of a 32-byte issuer public key>"
62
+
63
+ functions:
64
+ read_logs:
65
+ _type: read_logs
66
+ middleware: [task_authorization]
67
+ ```
68
+
69
+ `trusted_roots` selects accepted issuers and cannot be empty. A denied call
70
+ raises `AuthorizationDenied`; a call needing a signed approval raises
71
+ `ApprovalRequired`, which subclasses it. The middleware is not final, so later
72
+ middleware continues after an allow.
73
+
74
+ ## Compatibility and verification
75
+
76
+ Tested with Python 3.11–3.13, `nvidia-nat-core` 1.8.x, and
77
+ Tenuo 0.3.x. Run its tests and distribution build with:
78
+
79
+ ```bash
80
+ uv run --locked --project python/nemo-agent-toolkit-tenuo --extra test \
81
+ pytest python/nemo-agent-toolkit-tenuo/tests -q
82
+ uv build --project python/nemo-agent-toolkit-tenuo
83
+ ```
84
+
85
+ See the repository [security policy](../../SECURITY.md) before reporting a
86
+ vulnerability and [release guide](../../docs/releasing.md) for the publication
87
+ gate.
88
+
89
+ ## License
90
+
91
+ Apache-2.0.
@@ -0,0 +1,54 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [tool.hatch.build.targets.wheel]
6
+ packages = ["src/nat"]
7
+
8
+ [tool.hatch.build.targets.sdist]
9
+ # This repository-level integration test imports examples outside this package.
10
+ exclude = ["tests/test_outcome_matrix.py"]
11
+
12
+ [project]
13
+ name = "nemo-agent-toolkit-tenuo"
14
+ version = "0.1.0"
15
+ description = "Task-scoped Tenuo authorization for NVIDIA NeMo Agent Toolkit"
16
+ readme = "README.md"
17
+ requires-python = ">=3.11,<3.14"
18
+ license = "Apache-2.0"
19
+ keywords = ["authorization", "agents", "nvidia", "nemo-agent-toolkit", "security"]
20
+ classifiers = [
21
+ "Development Status :: 3 - Alpha",
22
+ "License :: OSI Approved :: Apache Software License",
23
+ "Operating System :: OS Independent",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Topic :: Security",
28
+ ]
29
+ dependencies = [
30
+ "nvidia-nat-core>=1.8,<1.9",
31
+ # nvidia-nat-core 1.8 imports packaging (nat info, the registry handlers)
32
+ # without declaring it, so a fresh environment cannot list plugins.
33
+ "packaging>=23",
34
+ "tenuo>=0.3.2,<0.4",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ test = [
39
+ "nvidia-nat-test>=1.8,<1.9",
40
+ "pytest>=8.0",
41
+ "pytest-asyncio>=0.24",
42
+ ]
43
+
44
+ [project.urls]
45
+ Documentation = "https://github.com/tenuo-ai/tenuo-openshell/tree/main/python/nemo-agent-toolkit-tenuo"
46
+ Issues = "https://github.com/tenuo-ai/tenuo-openshell/issues"
47
+ Source = "https://github.com/tenuo-ai/tenuo-openshell"
48
+
49
+ [project.entry-points."nat.plugins"]
50
+ nat_tenuo = "nat.plugins.tenuo.register"
51
+
52
+ [tool.pytest.ini_options]
53
+ asyncio_mode = "auto"
54
+ pythonpath = ["src"]
@@ -0,0 +1,15 @@
1
+ """Authorize NeMo Agent Toolkit function calls with a task-scoped Tenuo warrant."""
2
+
3
+ from nat.plugins.tenuo.context import authority
4
+ from nat.plugins.tenuo.middleware import ApprovalRequired
5
+ from nat.plugins.tenuo.middleware import AuthorizationDenied
6
+ from nat.plugins.tenuo.middleware import TenuoFunctionMiddleware
7
+ from nat.plugins.tenuo.middleware import TenuoMiddlewareConfig
8
+
9
+ __all__ = [
10
+ "ApprovalRequired",
11
+ "AuthorizationDenied",
12
+ "TenuoFunctionMiddleware",
13
+ "TenuoMiddlewareConfig",
14
+ "authority",
15
+ ]
@@ -0,0 +1,32 @@
1
+ """Task-local warrant binding.
2
+
3
+ The active warrant is a ``ContextVar``. Function arguments, model output, and
4
+ other tasks cannot select it.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from contextlib import contextmanager
10
+ from contextvars import ContextVar
11
+ from typing import Iterator
12
+
13
+ from tenuo import BoundWarrant
14
+
15
+ _bound: ContextVar[BoundWarrant | None] = ContextVar("tenuo_nat_bound_warrant", default=None)
16
+
17
+
18
+ def current_bound() -> BoundWarrant | None:
19
+ """Return the warrant bound to the current task, if any."""
20
+ return _bound.get()
21
+
22
+
23
+ @contextmanager
24
+ def authority(bound: BoundWarrant) -> Iterator[BoundWarrant]:
25
+ """Bind ``bound`` for the current task and restore the previous value on exit."""
26
+ if not isinstance(bound, BoundWarrant):
27
+ raise TypeError("authority() requires a BoundWarrant")
28
+ token = _bound.set(bound)
29
+ try:
30
+ yield bound
31
+ finally:
32
+ _bound.reset(token)