metano-agent-sdk 0.7.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.
- metano_agent_sdk-0.7.0/.gitignore +8 -0
- metano_agent_sdk-0.7.0/LICENSE +201 -0
- metano_agent_sdk-0.7.0/NOTICE +10 -0
- metano_agent_sdk-0.7.0/PKG-INFO +185 -0
- metano_agent_sdk-0.7.0/README.md +140 -0
- metano_agent_sdk-0.7.0/pyproject.toml +134 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/__init__.py +966 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_config.py +99 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_detect.py +137 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_envelope.py +143 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_gateway.py +68 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_guardrails.py +1106 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_k8s.py +119 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_mcp_identity.py +198 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_realm.py +134 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_route.py +123 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_session.py +886 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/_transport.py +116 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/a2a.py +1682 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/crewai.py +941 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/langchain.py +999 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/langchain_middleware.py +468 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/mcp.py +113 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/openai_agents.py +584 -0
- metano_agent_sdk-0.7.0/src/metano_agent_sdk/py.typed +0 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or 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, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Metano AI
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metano Agent SDK for Python
|
|
2
|
+
Copyright 2026 Metano AI
|
|
3
|
+
|
|
4
|
+
This product includes software developed at Metano AI.
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: metano-agent-sdk
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Instrument your own AI agents (LangChain, CrewAI, OpenAI Agents SDK, or plain Python) for Metano: session telemetry and runtime guardrails.
|
|
5
|
+
Project-URL: Homepage, https://metano.ai
|
|
6
|
+
Author: Metano AI
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
Keywords: agent,ai,crewai,guardrails,langchain,llm,mcp,observability,security
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Security
|
|
21
|
+
Classifier: Topic :: System :: Monitoring
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Provides-Extra: a2a
|
|
25
|
+
Requires-Dist: a2a-sdk[http-server]<2,>=1.1.2; extra == 'a2a'
|
|
26
|
+
Provides-Extra: crewai
|
|
27
|
+
Requires-Dist: crewai<2,>=1.14; extra == 'crewai'
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: a2a-sdk[http-server]<2,>=1.1.2; extra == 'dev'
|
|
30
|
+
Requires-Dist: langchain-core>=0.3; extra == 'dev'
|
|
31
|
+
Requires-Dist: langchain>=1.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: mypy==1.13.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest==8.3.4; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff==0.8.4; extra == 'dev'
|
|
35
|
+
Requires-Dist: wrapt>=1.16; extra == 'dev'
|
|
36
|
+
Provides-Extra: langchain
|
|
37
|
+
Requires-Dist: langchain-core>=0.3; extra == 'langchain'
|
|
38
|
+
Provides-Extra: langchain-agents
|
|
39
|
+
Requires-Dist: langchain>=1.0; extra == 'langchain-agents'
|
|
40
|
+
Provides-Extra: mcp
|
|
41
|
+
Requires-Dist: wrapt>=1.16; extra == 'mcp'
|
|
42
|
+
Provides-Extra: openai-agents
|
|
43
|
+
Requires-Dist: openai-agents<1,>=0.2; extra == 'openai-agents'
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
|
|
46
|
+
# metano-agent-sdk
|
|
47
|
+
|
|
48
|
+
Instrument a Python AI agent for [Metano](https://metano.ai). The SDK reports
|
|
49
|
+
session traces, model calls, tool calls and your MCP server inventory, and it
|
|
50
|
+
enforces guardrail policy at runtime.
|
|
51
|
+
|
|
52
|
+
It works with LangChain, CrewAI and the OpenAI Agents SDK through adapters
|
|
53
|
+
that instrument automatically, and with any other framework, or none at all,
|
|
54
|
+
through the core API.
|
|
55
|
+
|
|
56
|
+
- **Python ≥ 3.10**. The core has **no dependencies**; framework adapters are
|
|
57
|
+
optional extras.
|
|
58
|
+
- **Apache-2.0**
|
|
59
|
+
- Telemetry is **fail-open**: the SDK never raises into, blocks, or delays your
|
|
60
|
+
agent. If Metano is unreachable, events are dropped and your agent keeps
|
|
61
|
+
running.
|
|
62
|
+
- Prompt, response, and tool bodies are **not** sent in full by default. You get
|
|
63
|
+
a short excerpt plus a hash. Opt in with `capture_content=True`.
|
|
64
|
+
|
|
65
|
+
## Install
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
pip install metano-agent-sdk
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Add the extra for your framework:
|
|
72
|
+
|
|
73
|
+
| Extra | Installs | For |
|
|
74
|
+
| --- | --- | --- |
|
|
75
|
+
| `langchain` | `langchain-core` | recording LangChain and LangGraph runs |
|
|
76
|
+
| `langchain-agents` | `langchain` 1.x | the guardrail middleware for `create_agent` |
|
|
77
|
+
| `crewai` | `crewai` 1.x | recording and guarding CrewAI crews and flows |
|
|
78
|
+
| `openai-agents` | `openai-agents` | recording and guarding the OpenAI Agents SDK |
|
|
79
|
+
| `a2a` | `a2a-sdk` | carrying session context across agent-to-agent calls |
|
|
80
|
+
| `mcp` | `wrapt` | recording calls made with the official `mcp` client |
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
pip install 'metano-agent-sdk[langchain]'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Configure
|
|
87
|
+
|
|
88
|
+
Create an API key on the **API Keys** page of the Metano portal (requires the
|
|
89
|
+
Admin role), then set it in your agent's environment:
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
export METANO_API_KEY=mo_...
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
That is all a production agent needs. The key names the deployment that issued
|
|
96
|
+
it, so the SDK works out where to send telemetry on its own.
|
|
97
|
+
|
|
98
|
+
## Quick start
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
import metano_agent_sdk as metano
|
|
102
|
+
|
|
103
|
+
metano.init(agent_name="refund-bot") # API key from $METANO_API_KEY
|
|
104
|
+
|
|
105
|
+
with metano.session() as s:
|
|
106
|
+
s.prompt("How many refunds are pending?")
|
|
107
|
+
|
|
108
|
+
with s.llm_call(model="claude-sonnet-5", provider="anthropic") as call:
|
|
109
|
+
answer = my_llm(...) # your real LLM client
|
|
110
|
+
call.usage(tokens_in=18, tokens_out=120) # feeds cost and token rollups
|
|
111
|
+
|
|
112
|
+
with s.tool_call("warehouse.query", kind="mcp", server="warehouse",
|
|
113
|
+
tool_input={"sql": "select ..."}) as tool:
|
|
114
|
+
tool.output(my_query(...)) # your real tool call
|
|
115
|
+
|
|
116
|
+
metano.shutdown() # flush buffered telemetry before a short-lived process exits
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The agent then appears under **AI Agents** in the portal, marked as an SDK
|
|
120
|
+
agent, with each session on its timeline.
|
|
121
|
+
|
|
122
|
+
### Always call `shutdown()`
|
|
123
|
+
|
|
124
|
+
Telemetry is batched and sent from a background thread so it never slows your
|
|
125
|
+
agent down. A short-lived process that exits without `metano.shutdown()` (or
|
|
126
|
+
`await metano.ashutdown()`) can lose the events still in its buffer.
|
|
127
|
+
|
|
128
|
+
## Frameworks
|
|
129
|
+
|
|
130
|
+
Pass your framework to `init()` and run your agent unchanged:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
metano.init(agent_name="research-bot", framework="langchain")
|
|
134
|
+
agent.invoke(inputs) # recorded automatically
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
metano.init(agent_name="research-bot", framework="crewai")
|
|
139
|
+
crew.kickoff(inputs={...}) # recorded and guarded automatically
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
metano.init(agent_name="research-bot", framework="openai-agents")
|
|
144
|
+
agent = Agent(...) # construct agents AFTER init()
|
|
145
|
+
await Runner.run(agent, "...")
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
For enforcement in a LangChain `create_agent` agent, add the middleware
|
|
149
|
+
(`langchain-agents` extra):
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from langchain.agents import create_agent
|
|
153
|
+
from metano_agent_sdk.langchain_middleware import MetanoGuardrailMiddleware
|
|
154
|
+
|
|
155
|
+
agent = create_agent(model=..., tools=[...], middleware=[MetanoGuardrailMiddleware()])
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
To record tool calls made through the official `mcp` client (`mcp` extra):
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from metano_agent_sdk.mcp import enable_mcp_capture
|
|
162
|
+
|
|
163
|
+
enable_mcp_capture()
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Environment variables
|
|
167
|
+
|
|
168
|
+
| Variable | Purpose |
|
|
169
|
+
| --- | --- |
|
|
170
|
+
| `METANO_API_KEY` | Your Metano API key. Required. |
|
|
171
|
+
| `METANO_INGEST_URL` | Override where telemetry is sent. |
|
|
172
|
+
| `METANO_GATEWAY_URL` | Override the LLM gateway address. |
|
|
173
|
+
| `METANO_MCP_GATEWAY_URL` | Override the MCP gateway address. |
|
|
174
|
+
|
|
175
|
+
Each override is optional; an explicit argument to `init()` wins over the
|
|
176
|
+
environment.
|
|
177
|
+
|
|
178
|
+
## Documentation
|
|
179
|
+
|
|
180
|
+
Full setup guides for each framework, guardrails and the LLM and MCP gateways
|
|
181
|
+
are in the Metano documentation, linked from the portal's **API Keys** page.
|
|
182
|
+
|
|
183
|
+
## License
|
|
184
|
+
|
|
185
|
+
Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# metano-agent-sdk
|
|
2
|
+
|
|
3
|
+
Instrument a Python AI agent for [Metano](https://metano.ai). The SDK reports
|
|
4
|
+
session traces, model calls, tool calls and your MCP server inventory, and it
|
|
5
|
+
enforces guardrail policy at runtime.
|
|
6
|
+
|
|
7
|
+
It works with LangChain, CrewAI and the OpenAI Agents SDK through adapters
|
|
8
|
+
that instrument automatically, and with any other framework, or none at all,
|
|
9
|
+
through the core API.
|
|
10
|
+
|
|
11
|
+
- **Python ≥ 3.10**. The core has **no dependencies**; framework adapters are
|
|
12
|
+
optional extras.
|
|
13
|
+
- **Apache-2.0**
|
|
14
|
+
- Telemetry is **fail-open**: the SDK never raises into, blocks, or delays your
|
|
15
|
+
agent. If Metano is unreachable, events are dropped and your agent keeps
|
|
16
|
+
running.
|
|
17
|
+
- Prompt, response, and tool bodies are **not** sent in full by default. You get
|
|
18
|
+
a short excerpt plus a hash. Opt in with `capture_content=True`.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
pip install metano-agent-sdk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Add the extra for your framework:
|
|
27
|
+
|
|
28
|
+
| Extra | Installs | For |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| `langchain` | `langchain-core` | recording LangChain and LangGraph runs |
|
|
31
|
+
| `langchain-agents` | `langchain` 1.x | the guardrail middleware for `create_agent` |
|
|
32
|
+
| `crewai` | `crewai` 1.x | recording and guarding CrewAI crews and flows |
|
|
33
|
+
| `openai-agents` | `openai-agents` | recording and guarding the OpenAI Agents SDK |
|
|
34
|
+
| `a2a` | `a2a-sdk` | carrying session context across agent-to-agent calls |
|
|
35
|
+
| `mcp` | `wrapt` | recording calls made with the official `mcp` client |
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
pip install 'metano-agent-sdk[langchain]'
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Configure
|
|
42
|
+
|
|
43
|
+
Create an API key on the **API Keys** page of the Metano portal (requires the
|
|
44
|
+
Admin role), then set it in your agent's environment:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
export METANO_API_KEY=mo_...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
That is all a production agent needs. The key names the deployment that issued
|
|
51
|
+
it, so the SDK works out where to send telemetry on its own.
|
|
52
|
+
|
|
53
|
+
## Quick start
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
import metano_agent_sdk as metano
|
|
57
|
+
|
|
58
|
+
metano.init(agent_name="refund-bot") # API key from $METANO_API_KEY
|
|
59
|
+
|
|
60
|
+
with metano.session() as s:
|
|
61
|
+
s.prompt("How many refunds are pending?")
|
|
62
|
+
|
|
63
|
+
with s.llm_call(model="claude-sonnet-5", provider="anthropic") as call:
|
|
64
|
+
answer = my_llm(...) # your real LLM client
|
|
65
|
+
call.usage(tokens_in=18, tokens_out=120) # feeds cost and token rollups
|
|
66
|
+
|
|
67
|
+
with s.tool_call("warehouse.query", kind="mcp", server="warehouse",
|
|
68
|
+
tool_input={"sql": "select ..."}) as tool:
|
|
69
|
+
tool.output(my_query(...)) # your real tool call
|
|
70
|
+
|
|
71
|
+
metano.shutdown() # flush buffered telemetry before a short-lived process exits
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The agent then appears under **AI Agents** in the portal, marked as an SDK
|
|
75
|
+
agent, with each session on its timeline.
|
|
76
|
+
|
|
77
|
+
### Always call `shutdown()`
|
|
78
|
+
|
|
79
|
+
Telemetry is batched and sent from a background thread so it never slows your
|
|
80
|
+
agent down. A short-lived process that exits without `metano.shutdown()` (or
|
|
81
|
+
`await metano.ashutdown()`) can lose the events still in its buffer.
|
|
82
|
+
|
|
83
|
+
## Frameworks
|
|
84
|
+
|
|
85
|
+
Pass your framework to `init()` and run your agent unchanged:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
metano.init(agent_name="research-bot", framework="langchain")
|
|
89
|
+
agent.invoke(inputs) # recorded automatically
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
metano.init(agent_name="research-bot", framework="crewai")
|
|
94
|
+
crew.kickoff(inputs={...}) # recorded and guarded automatically
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
metano.init(agent_name="research-bot", framework="openai-agents")
|
|
99
|
+
agent = Agent(...) # construct agents AFTER init()
|
|
100
|
+
await Runner.run(agent, "...")
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
For enforcement in a LangChain `create_agent` agent, add the middleware
|
|
104
|
+
(`langchain-agents` extra):
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from langchain.agents import create_agent
|
|
108
|
+
from metano_agent_sdk.langchain_middleware import MetanoGuardrailMiddleware
|
|
109
|
+
|
|
110
|
+
agent = create_agent(model=..., tools=[...], middleware=[MetanoGuardrailMiddleware()])
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
To record tool calls made through the official `mcp` client (`mcp` extra):
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from metano_agent_sdk.mcp import enable_mcp_capture
|
|
117
|
+
|
|
118
|
+
enable_mcp_capture()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Environment variables
|
|
122
|
+
|
|
123
|
+
| Variable | Purpose |
|
|
124
|
+
| --- | --- |
|
|
125
|
+
| `METANO_API_KEY` | Your Metano API key. Required. |
|
|
126
|
+
| `METANO_INGEST_URL` | Override where telemetry is sent. |
|
|
127
|
+
| `METANO_GATEWAY_URL` | Override the LLM gateway address. |
|
|
128
|
+
| `METANO_MCP_GATEWAY_URL` | Override the MCP gateway address. |
|
|
129
|
+
|
|
130
|
+
Each override is optional; an explicit argument to `init()` wins over the
|
|
131
|
+
environment.
|
|
132
|
+
|
|
133
|
+
## Documentation
|
|
134
|
+
|
|
135
|
+
Full setup guides for each framework, guardrails and the LLM and MCP gateways
|
|
136
|
+
are in the Metano documentation, linked from the portal's **API Keys** page.
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
# 1.27 is the first hatchling that writes PEP 639 `License-File` metadata from
|
|
3
|
+
# `license-files` below; older ones silently ship the wheel without LICENSE.
|
|
4
|
+
requires = ["hatchling>=1.27"]
|
|
5
|
+
build-backend = "hatchling.build"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "metano-agent-sdk"
|
|
9
|
+
# Hand-bumped in the change that alters the SDK, independently of the Metano
|
|
10
|
+
# platform's own release numbers. A published version can never be replaced.
|
|
11
|
+
version = "0.7.0"
|
|
12
|
+
description = "Instrument your own AI agents (LangChain, CrewAI, OpenAI Agents SDK, or plain Python) for Metano: session telemetry and runtime guardrails."
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
license = "Apache-2.0"
|
|
16
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
17
|
+
authors = [{ name = "Metano AI" }]
|
|
18
|
+
keywords = ["ai", "agent", "llm", "observability", "guardrails", "security", "langchain", "crewai", "mcp"]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Development Status :: 4 - Beta",
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Topic :: Security",
|
|
30
|
+
"Topic :: System :: Monitoring",
|
|
31
|
+
"Typing :: Typed",
|
|
32
|
+
]
|
|
33
|
+
# Core is dependency-free — it builds JSON envelopes and POSTs them with the
|
|
34
|
+
# stdlib. Framework adapters live behind extras so the base install stays light
|
|
35
|
+
# in a customer's environment.
|
|
36
|
+
dependencies = []
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://metano.ai"
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
# Observe-only callback handler — langchain-core is enough.
|
|
43
|
+
langchain = ["langchain-core>=0.3"]
|
|
44
|
+
# Enforcement middleware — needs the full agent-middleware API (langchain 1.x).
|
|
45
|
+
langchain-agents = ["langchain>=1.0"]
|
|
46
|
+
# CrewAI adapter — telemetry via the crewai event bus + enforcement via the
|
|
47
|
+
# public crewai.hooks API (before/after llm + tool call). crewai is a heavy dep
|
|
48
|
+
# (pulls openai, chromadb, opentelemetry, ...) so it is deliberately NOT added
|
|
49
|
+
# to `dev`; the crewai test job installs `--extra crewai` on top of `--extra dev`.
|
|
50
|
+
crewai = ["crewai>=1.14,<2"]
|
|
51
|
+
# A2A delegation — the client interceptor and executor wrapper that carry the
|
|
52
|
+
# session chain + operating user across an agent-to-agent hop.
|
|
53
|
+
#
|
|
54
|
+
# `http-server` is included because the RECEIVING half needs a2a's starlette
|
|
55
|
+
# server pieces; a caller-only agent installs more than it uses, which is the
|
|
56
|
+
# cheaper mistake. Upper-bounded at <2 deliberately: the adapter relies on a2a
|
|
57
|
+
# internals that are not part of its documented API, so re-verify them against
|
|
58
|
+
# a live hop before widening it.
|
|
59
|
+
a2a = ["a2a-sdk[http-server]>=1.1.2,<2"]
|
|
60
|
+
# OpenAI Agents SDK adapter — telemetry via the SDK's own TracingProcessor
|
|
61
|
+
# pipeline + enforcement via input_guardrails/output_guardrails.
|
|
62
|
+
#
|
|
63
|
+
# Upper-bounded at <1 deliberately. The adapter reads span_data by CLASS NAME
|
|
64
|
+
# and attribute rather than by importing the SDK's types (see the note in
|
|
65
|
+
# openai_agents.py), which survives field additions but not a rename of
|
|
66
|
+
# GenerationSpanData or FunctionSpanData. Re-check the mapping before widening.
|
|
67
|
+
openai-agents = ["openai-agents>=0.2,<1"]
|
|
68
|
+
# MCP client capture (`metano_agent_sdk.mcp.enable_mcp_capture`) patches the
|
|
69
|
+
# official client with wrapt. The `mcp` client itself is the caller's own
|
|
70
|
+
# dependency, so it is not pulled in here.
|
|
71
|
+
mcp = ["wrapt>=1.16"]
|
|
72
|
+
dev = [
|
|
73
|
+
"pytest==8.3.4",
|
|
74
|
+
"ruff==0.8.4",
|
|
75
|
+
"mypy==1.13.0",
|
|
76
|
+
"wrapt>=1.16",
|
|
77
|
+
"langchain-core>=0.3",
|
|
78
|
+
"langchain>=1.0",
|
|
79
|
+
# In `dev` (unlike crewai) because it is comparatively light and pulls no
|
|
80
|
+
# `mcp`, so it cannot perturb test_mcp's "requires the mcp package"
|
|
81
|
+
# assertion the way crewai's transitive deps do.
|
|
82
|
+
"a2a-sdk[http-server]>=1.1.2,<2",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
[tool.hatch.build.targets.wheel]
|
|
86
|
+
packages = ["src/metano_agent_sdk"]
|
|
87
|
+
|
|
88
|
+
# The sdist is an allowlist: the package, its metadata and its licence.
|
|
89
|
+
# Without it, hatchling would also ship the tests, examples and development
|
|
90
|
+
# tooling that live next to the package.
|
|
91
|
+
[tool.hatch.build.targets.sdist]
|
|
92
|
+
only-include = ["src/metano_agent_sdk", "README.md", "LICENSE", "NOTICE", "pyproject.toml"]
|
|
93
|
+
|
|
94
|
+
[tool.ruff]
|
|
95
|
+
line-length = 100
|
|
96
|
+
# The LINT target, deliberately below the 3.10 package floor: Kubernetes
|
|
97
|
+
# auto-instrumentation can load this source into application images whatever
|
|
98
|
+
# their CPython, and a 3.10 target makes ruff ask for constructs that raise on
|
|
99
|
+
# 3.9 (`zip(strict=)`, `isinstance(x, A | B)`). Python 3.9 is best-effort only
|
|
100
|
+
# and is not tested. mypy below checks against the real 3.10 floor.
|
|
101
|
+
target-version = "py39"
|
|
102
|
+
|
|
103
|
+
[tool.ruff.lint]
|
|
104
|
+
select = ["E", "F", "I", "B", "UP", "SIM", "RET", "PLE"]
|
|
105
|
+
ignore = ["E501"]
|
|
106
|
+
|
|
107
|
+
[tool.pytest.ini_options]
|
|
108
|
+
testpaths = ["tests"]
|
|
109
|
+
|
|
110
|
+
[tool.mypy]
|
|
111
|
+
python_version = "3.10"
|
|
112
|
+
ignore_missing_imports = true
|
|
113
|
+
|
|
114
|
+
[[tool.mypy.overrides]]
|
|
115
|
+
# anyio (pulled transitively via the optional langchain deps) ships py.typed, so
|
|
116
|
+
# mypy analyzes its source. Treat it as untyped at the boundary.
|
|
117
|
+
module = ["anyio.*"]
|
|
118
|
+
follow_imports = "skip"
|
|
119
|
+
|
|
120
|
+
[[tool.mypy.overrides]]
|
|
121
|
+
# crewai (and its transitive `mcp`) are a fast-moving external boundary. Treat
|
|
122
|
+
# them as untyped (same rationale as anyio above) — the crewai adapter reads
|
|
123
|
+
# CrewAI events/contexts via getattr, so it doesn't rely on CrewAI's own types.
|
|
124
|
+
# Only matters when the crewai extra is installed.
|
|
125
|
+
module = ["crewai.*", "mcp.*"]
|
|
126
|
+
follow_imports = "skip"
|
|
127
|
+
|
|
128
|
+
[[tool.mypy.overrides]]
|
|
129
|
+
# a2a-sdk is treated as untyped at the boundary, like the two above. The a2a
|
|
130
|
+
# adapter subclasses two of its ABCs and otherwise reads the request objects
|
|
131
|
+
# field by field, so little is lost, and the real shapes are verified against a
|
|
132
|
+
# live agent-to-agent call.
|
|
133
|
+
module = ["a2a.*"]
|
|
134
|
+
follow_imports = "skip"
|