xtrom-sdk 0.5.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.
- xtrom_sdk-0.5.0/.gitignore +1 -0
- xtrom_sdk-0.5.0/LICENSE +190 -0
- xtrom_sdk-0.5.0/PKG-INFO +244 -0
- xtrom_sdk-0.5.0/README.md +219 -0
- xtrom_sdk-0.5.0/browser_scenarios.json +350 -0
- xtrom_sdk-0.5.0/pyproject.toml +46 -0
- xtrom_sdk-0.5.0/tests/test_adapters.py +244 -0
- xtrom_sdk-0.5.0/tests/test_appliers.py +88 -0
- xtrom_sdk-0.5.0/tests/test_contract_ingest.py +101 -0
- xtrom_sdk-0.5.0/tests/test_credentials.py +43 -0
- xtrom_sdk-0.5.0/tests/test_directive.py +63 -0
- xtrom_sdk-0.5.0/tests/test_hook_strict.py +63 -0
- xtrom_sdk-0.5.0/tests/test_inventory.py +73 -0
- xtrom_sdk-0.5.0/tests/test_local.py +894 -0
- xtrom_sdk-0.5.0/tests/test_local_view.py +159 -0
- xtrom_sdk-0.5.0/tests/test_memory_provenance.py +132 -0
- xtrom_sdk-0.5.0/tests/test_sdk.py +966 -0
- xtrom_sdk-0.5.0/tests/test_updater.py +211 -0
- xtrom_sdk-0.5.0/tests/test_workspace_mode.py +195 -0
- xtrom_sdk-0.5.0/xtrom_sdk/__init__.py +21 -0
- xtrom_sdk-0.5.0/xtrom_sdk/__main__.py +11 -0
- xtrom_sdk-0.5.0/xtrom_sdk/adapters/__init__.py +322 -0
- xtrom_sdk-0.5.0/xtrom_sdk/adapters/anthropic.py +7 -0
- xtrom_sdk-0.5.0/xtrom_sdk/adapters/crewai.py +7 -0
- xtrom_sdk-0.5.0/xtrom_sdk/adapters/langchain.py +7 -0
- xtrom_sdk-0.5.0/xtrom_sdk/adapters/openai.py +7 -0
- xtrom_sdk-0.5.0/xtrom_sdk/credentials.py +52 -0
- xtrom_sdk-0.5.0/xtrom_sdk/directive.py +85 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/__init__.py +0 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/agents.py +423 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/appliers.py +116 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/browser.py +186 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/cli.py +204 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/discover.py +117 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/hook.py +775 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/install.py +219 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/inventory.py +268 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/shipper.py +325 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/spool.py +228 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/state.py +193 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/update_keys.py +3 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/updater.py +268 -0
- xtrom_sdk-0.5.0/xtrom_sdk/local/view.py +158 -0
- xtrom_sdk-0.5.0/xtrom_sdk/memory_store.py +49 -0
- xtrom_sdk-0.5.0/xtrom_sdk/reporter.py +435 -0
- xtrom_sdk-0.5.0/xtrom_sdk/session.py +435 -0
- xtrom_sdk-0.5.0/xtrom_sdk/workspace.py +82 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.local-test-state/
|
xtrom_sdk-0.5.0/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
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.
|
|
111
|
+
|
|
112
|
+
You may add Your own copyright statement to Your modifications and
|
|
113
|
+
may provide additional or different license terms and conditions
|
|
114
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
115
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
116
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
117
|
+
the conditions stated in this License.
|
|
118
|
+
|
|
119
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
120
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
121
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
122
|
+
this License, without any additional terms or conditions.
|
|
123
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
124
|
+
the terms of any separate license agreement you may have executed
|
|
125
|
+
with Licensor regarding such Contributions.
|
|
126
|
+
|
|
127
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
128
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
129
|
+
except as required for reasonable and customary use in describing the
|
|
130
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
131
|
+
|
|
132
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
133
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
134
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
135
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
136
|
+
implied, including, without limitation, any warranties or conditions
|
|
137
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
138
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
139
|
+
appropriateness of using or redistributing the Work and assume any
|
|
140
|
+
risks associated with Your exercise of permissions under this License.
|
|
141
|
+
|
|
142
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
143
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
144
|
+
unless required by applicable law (such as deliberate and grossly
|
|
145
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
146
|
+
liable to You for damages, including any direct, indirect, special,
|
|
147
|
+
incidental, or consequential damages of any character arising as a
|
|
148
|
+
result of this License or out of the use or inability to use the
|
|
149
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
150
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
151
|
+
other commercial damages or losses), even if such Contributor
|
|
152
|
+
has been advised of the possibility of such damages.
|
|
153
|
+
|
|
154
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
155
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
156
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
157
|
+
or other liability obligations and/or rights consistent with this
|
|
158
|
+
License. However, in accepting such obligations, You may act only
|
|
159
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
160
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
161
|
+
defend, and hold each Contributor harmless for any liability
|
|
162
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
163
|
+
of your accepting any such warranty or additional liability.
|
|
164
|
+
|
|
165
|
+
END OF TERMS AND CONDITIONS
|
|
166
|
+
|
|
167
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
168
|
+
|
|
169
|
+
To apply the Apache License to your work, attach the following
|
|
170
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
171
|
+
replaced with your own identifying information. (Don't include
|
|
172
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
173
|
+
comment syntax for the file format. We also recommend that a
|
|
174
|
+
file or class name and description of purpose be included on the
|
|
175
|
+
same "printed page" as the copyright notice for easier
|
|
176
|
+
identification within third-party archives.
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Xtrom
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
xtrom_sdk-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: xtrom-sdk
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Xtrom SDK — wrap AI-agent tools with runtime enforcement (taint/IFC + policy).
|
|
5
|
+
Project-URL: Homepage, https://github.com/xtrom-ai/xtrom
|
|
6
|
+
Project-URL: Source, https://github.com/xtrom-ai/xtrom/tree/main/product/xtrom-sdk-python
|
|
7
|
+
Project-URL: Issues, https://github.com/xtrom-ai/xtrom/issues
|
|
8
|
+
Author: Xtrom
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai-agents,guardrails,llm,mcp,prompt-injection,security,taint-tracking
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Security
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: xtrom-engine>=0.3.1
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
22
|
+
Provides-Extra: update
|
|
23
|
+
Requires-Dist: cryptography>=42; extra == 'update'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# xtrom-sdk-python ✅ built & tested (6/6)
|
|
27
|
+
|
|
28
|
+
Thin Python SDK / middleware that wraps agent frameworks (LangGraph, CrewAI, Bedrock Agents,
|
|
29
|
+
LlamaIndex) and enforces via `xtrom-engine`. For teams that want in-process enforcement
|
|
30
|
+
without running the gateway.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
```bash
|
|
34
|
+
pip install xtrom-sdk --no-index --find-links https://console.xtrom.ai/pkgs/index.html
|
|
35
|
+
```
|
|
36
|
+
The SDK is self-hosted, not on PyPI. Each deploy builds the `xtrom-sdk` and `xtrom-engine` wheels
|
|
37
|
+
into the console's `/pkgs/` page, and **Govern › Connect** shows this line for your environment.
|
|
38
|
+
Public PyPI/npm publishing is opt-in (`PUBLISH_SDK=true` in `.github/workflows/publish.yml`).
|
|
39
|
+
|
|
40
|
+
> **Windows / `pip install --user`:** if `xtrom` prints *"not recognized as a command"*, the
|
|
41
|
+
> per-user Scripts dir (e.g. `%APPDATA%\Python\Python3xx\Scripts`) isn't on PATH — pip warns about
|
|
42
|
+
> this at install time. Run the CLI as a module instead; it's identical to the `xtrom` launcher.
|
|
43
|
+
> Use `py` (the python.org launcher); if you don't have it, swap in `python`:
|
|
44
|
+
> ```bash
|
|
45
|
+
> py -m xtrom_sdk install --url https://api.xtrom.ai --token-stdin
|
|
46
|
+
> ```
|
|
47
|
+
|
|
48
|
+
`--token-stdin` keeps the token out of argv and shell history — paste it at the hidden prompt, or
|
|
49
|
+
set `XTROM_INSTALL_TOKEN` (CI). `--token <TOKEN>` still works for throwaway scripts.
|
|
50
|
+
|
|
51
|
+
## Protect your local coding agent
|
|
52
|
+
Xtrom protects your coding agents locally through each agent's official command hooks. One
|
|
53
|
+
decision engine serves them all; a small adapter per agent (`xtrom_sdk/local/agents.py`) speaks
|
|
54
|
+
that agent's hook protocol.
|
|
55
|
+
|
|
56
|
+
No account needed: decisions are made on this machine and nothing is sent anywhere.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pipx install xtrom # or: uvx xtrom install (`xtrom` is the short name for xtrom-sdk)
|
|
60
|
+
xtrom install # every coding agent found on this machine, user scope
|
|
61
|
+
xtrom install --agent cursor,codex # or pick: claude (claude-code), copilot, cursor, codex, gemini, windsurf, all
|
|
62
|
+
xtrom install --project # this repo only
|
|
63
|
+
xtrom install --monitor # observe and audit, never deny
|
|
64
|
+
xtrom log # what Xtrom stopped (--all for everything, --since 2h, --json)
|
|
65
|
+
xtrom status # what's protected (--json for scripts); --agent narrows it
|
|
66
|
+
xtrom connect --url https://api.xtrom.ai --token-stdin # optional: report to your team's console (--off stops)
|
|
67
|
+
xtrom uninstall
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| Agent | `--agent` | Hook config (user · `--project`) | "ask" verdict |
|
|
71
|
+
|---|---|---|---|
|
|
72
|
+
| Claude Code | `claude` | `~/.claude/settings.json` · `.claude/settings.json` | asks you |
|
|
73
|
+
| GitHub Copilot CLI | `copilot` | `~/.copilot/hooks/xtrom.json` · `.github/hooks/xtrom.json` | asks you |
|
|
74
|
+
| Cursor | `cursor` | `~/.cursor/hooks.json` · `.cursor/hooks.json` | blocked¹ |
|
|
75
|
+
| OpenAI Codex CLI | `codex` | `~/.codex/hooks.json` · `.codex/hooks.json` | blocked¹ |
|
|
76
|
+
| Gemini CLI | `gemini` | `~/.gemini/settings.json` · `.gemini/settings.json` | blocked¹ |
|
|
77
|
+
| Windsurf | `windsurf` | `~/.codeium/windsurf/hooks.json` · `.devin/hooks.json` | blocked¹ |
|
|
78
|
+
|
|
79
|
+
¹ These agents' hooks can't pause for a human, so Xtrom fails closed: the call is blocked and the
|
|
80
|
+
reason tells you to run it yourself in a terminal if you meant it. Codex asks you to trust new
|
|
81
|
+
hooks once: open Codex and approve Xtrom in `/hooks`. Windsurf has no web-fetch hook, so its
|
|
82
|
+
untrusted-input signal comes from MCP tools and `curl`/`gh` output.
|
|
83
|
+
|
|
84
|
+
The hook registers for each agent's before-tool and after-tool events. Web results, every MCP tool's output, and
|
|
85
|
+
`curl`/`gh` output are marked as untrusted session context. After that, any shell command that
|
|
86
|
+
isn't recognised local dev work asks you. Writes to `~/.xtrom` are always denied, and changes to
|
|
87
|
+
any coding agent's hook or permission settings always ask. Later sinks such as file writes, shell commands, git pushes, and
|
|
88
|
+
outbound MCP tools are adjudicated by `xtrom-engine`. `BLOCK` becomes the agent's deny,
|
|
89
|
+
`STEP_UP` asks you (or blocks, where the agent can't ask), and `ALLOW` stays silent. Hook processes are short-lived, so Xtrom persists
|
|
90
|
+
only metadata taint state under `~/.xtrom/local/sessions/` and appends a metadata-only audit line
|
|
91
|
+
to `~/.xtrom/local/audit.jsonl` (tool name, verdict, reason code, taint origins, timestamp,
|
|
92
|
+
session id; no raw tool arguments). If state is corrupt or unreadable, Xtrom fails safe: it asks
|
|
93
|
+
before sink tools and stays silent for non-sinks.
|
|
94
|
+
|
|
95
|
+
**Reporting is decoupled from the short-lived hook.** When reporting is configured, each decision is
|
|
96
|
+
written to a local spool and a single **detached background shipper** process delivers it to your
|
|
97
|
+
console with retry/backoff — the hook never blocks a tool call on the network, and an undelivered
|
|
98
|
+
event survives the hook exiting (durable spool, redelivered on the next run). The shipper also emits a
|
|
99
|
+
liveness **heartbeat** so the console's Enforcement-health view shows the agent as live rather than
|
|
100
|
+
silent. Cross-platform: the shipper is spawned detached (POSIX `start_new_session` / Windows
|
|
101
|
+
`DETACHED_PROCESS`) and outlives the agent that started it.
|
|
102
|
+
|
|
103
|
+
**Updating (one-time refresh, then self-updating).** An agent already installed keeps running its
|
|
104
|
+
current version until refreshed **once** — `pip install -U xtrom-sdk --find-links <console>/pkgs/index.html`
|
|
105
|
+
then `xtrom install`. After that, signed updates self-apply per your console policy (approve/auto),
|
|
106
|
+
no manual command. (The very first update can't self-deliver: an old agent doesn't yet have the
|
|
107
|
+
background shipper that applies updates.)
|
|
108
|
+
|
|
109
|
+
Every agent runs the hook through a `/bin/sh` launcher. If this Python disappears or the hook
|
|
110
|
+
crashes, the launcher exits 2, which every supported agent treats as a block, so the call is
|
|
111
|
+
stopped rather than run unchecked. To fix it, re-run
|
|
112
|
+
`xtrom install` or `xtrom uninstall` from a terminal. `--url`/`--token` are stored 0600 in
|
|
113
|
+
`~/.xtrom/local/config.json`, never in your shell profile, where the agent could read them. Only
|
|
114
|
+
`https://` is accepted, except for localhost.
|
|
115
|
+
|
|
116
|
+
**Browser agents.** Browser automation runs through the Playwright, Puppeteer, Chrome DevTools,
|
|
117
|
+
Browserbase/Stagehand and Claude in Chrome MCP servers, and Anthropic's `computer` tool. Every page
|
|
118
|
+
the agent reads, including screenshots, marks the session untrusted. Xtrom then gates the moments
|
|
119
|
+
that have consequences, not every click:
|
|
120
|
+
|
|
121
|
+
| Browser action | Clean session | After untrusted content |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| Snapshot, screenshot, scroll, hover, typing into a field, ordinary clicks | allowed | allowed |
|
|
124
|
+
| Submit: `submit`/Enter, accepting a dialog, clicking Send/Pay/Delete/Sign in…, the first click after typing | allowed | **ask** |
|
|
125
|
+
| Navigate to a URL | allowed | **ask** |
|
|
126
|
+
| Run script in the page (`evaluate`, `run_code`), install extensions, mock routes; upload files | allowed | **ask** |
|
|
127
|
+
| Read or change cookies, localStorage or sessionStorage (including via script) | **ask** | **ask** |
|
|
128
|
+
| Type a secret (API key, token) into a page | **ask** | **deny** |
|
|
129
|
+
| Navigate to a URL carrying a secret; upload a credential file (`~/.ssh/id_rsa`, `.env`) | **deny** | **deny** |
|
|
130
|
+
|
|
131
|
+
The click-after-typing rule exists because a button's label is whatever the page or the model calls
|
|
132
|
+
it. Once data has been entered, the next click may be the one that sends it.
|
|
133
|
+
|
|
134
|
+
**What it is, and isn't.** This is a guardrail inside your coding agent, not a sandbox. It sees each
|
|
135
|
+
tool call the agent reports to its hooks and judges it from the command text. Known limits:
|
|
136
|
+
- In a session that hasn't read untrusted content, ordinary shell commands run without a prompt.
|
|
137
|
+
The hook assumes the agent's own instructions came from you.
|
|
138
|
+
- `npm test`, `make` and `npm run` stay silent after untrusted input, but they run code the agent
|
|
139
|
+
may have edited.
|
|
140
|
+
- A command's text isn't its behaviour. After untrusted input, anything not on the local-dev
|
|
141
|
+
allowlist asks you; a cleverly disguised command can still look harmless to you.
|
|
142
|
+
|
|
143
|
+
For real isolation, pair it with your agent's sandboxing and permission rules.
|
|
144
|
+
|
|
145
|
+
`xtrom discover` inventories MCP servers from common Claude, Cursor, Codex, and VS Code config
|
|
146
|
+
files and flags remote URLs or secret-looking env key names without printing secret values.
|
|
147
|
+
|
|
148
|
+
## In-process SDK and framework adapters
|
|
149
|
+
```python
|
|
150
|
+
from xtrom_sdk import Session
|
|
151
|
+
from xtrom_sdk.adapters import wrap_openai_tools, wrap_langchain_tool
|
|
152
|
+
|
|
153
|
+
session = Session("svc-support-bot")
|
|
154
|
+
|
|
155
|
+
def read_web(url: str) -> str: ...
|
|
156
|
+
def http_post(url: str, body: str) -> str: ...
|
|
157
|
+
|
|
158
|
+
dispatch = wrap_openai_tools(
|
|
159
|
+
session,
|
|
160
|
+
{"read_web": read_web, "http_post": http_post},
|
|
161
|
+
sources={"read_web"}, # output is untrusted ingress
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
tool_message = dispatch({
|
|
165
|
+
"id": "call_1",
|
|
166
|
+
"function": {"name": "read_web", "arguments": "{\"url\":\"https://docs.example\"}"},
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
safe_langchain_tool = wrap_langchain_tool(session, existing_tool, sources={"retriever"})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Adapters in `xtrom_sdk.adapters`:
|
|
173
|
+
|
|
174
|
+
- `wrap_openai_tools(session, tools, *, sources=...)` returns a dispatcher for OpenAI Chat
|
|
175
|
+
Completions / Responses tool calls. It parses the tool name and JSON arguments, adjudicates
|
|
176
|
+
through `Session` before execution, runs only on `ALLOW`, and returns a tool message. `BLOCK`
|
|
177
|
+
and `STEP_UP` return structured JSON content for the model instead of running the tool.
|
|
178
|
+
- `wrap_anthropic_tools(session, tools, *, sources=...)` does the same for Anthropic Messages
|
|
179
|
+
`tool_use` blocks and returns `tool_result` blocks.
|
|
180
|
+
- `wrap_langchain_tool(session, tool, ...)` wraps a LangChain/LangGraph-style tool by duck type
|
|
181
|
+
(`.name`, `.invoke` / `._run`) and preserves the callable interface.
|
|
182
|
+
- `wrap_crewai_tool(session, tool, ...)` wraps a CrewAI-style tool by duck type (`.name`,
|
|
183
|
+
`._run` / `.run`).
|
|
184
|
+
|
|
185
|
+
Framework packages are not hard dependencies; imports are lazy/duck-typed so the SDK imports
|
|
186
|
+
without OpenAI, Anthropic, LangChain, LangGraph, or CrewAI installed. Adapter tests use minimal
|
|
187
|
+
fake framework objects. Live framework CI is not wired yet; the supported contract is the stable
|
|
188
|
+
tool-call/tool object shape above.
|
|
189
|
+
|
|
190
|
+
## Session taint (on by default)
|
|
191
|
+
Once an agent reads untrusted content (a web page, an MCP tool result, an email), the model's
|
|
192
|
+
context is influenced even if the attacker's text is *paraphrased* before it reaches a sink.
|
|
193
|
+
`Session` therefore tracks two tiers of taint:
|
|
194
|
+
|
|
195
|
+
- **Value taint** (proven): untrusted bytes reach a sink argument → `BLOCK` (L3).
|
|
196
|
+
- **Context taint** (inferred): any sensitive sink after untrusted ingress in the same session → `STEP_UP`
|
|
197
|
+
(human approval), never a silent allow. It lasts for the whole `Session`: the model can carry a
|
|
198
|
+
reworded copy of untrusted content into a later task, so `new_task()` does not clear it.
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
s = Session("svc-support-bot") # session_taint=True by default
|
|
202
|
+
s.context_tainted # True after the first untrusted ingress
|
|
203
|
+
Session("svc-support-bot") # a genuinely fresh conversation: a new Session
|
|
204
|
+
Session("batch-bot", session_taint=False) # opt out (e.g. no untrusted inputs at all)
|
|
205
|
+
```
|
|
206
|
+
`@s.guard(source=True)` marks where a tool's *output* goes, not what the tool can do, so source
|
|
207
|
+
tools get no special exemption from context taint. Read-only tools (rated `LOW` in the policy,
|
|
208
|
+
e.g. `read_file`) are never held; a dual-use tool such as `execute_sql` or a generic MCP call is,
|
|
209
|
+
because a reworded write through it is exactly what context taint exists to catch. Rate genuine
|
|
210
|
+
read-only tools `LOW`; fetches to allowlisted hosts are fine. Tools in `Policy.context_taint_exempt`
|
|
211
|
+
are the explicit, auditable opt-out (e.g. a browsing agent). Every decision
|
|
212
|
+
shipped to the control plane carries `session_id` and `mode` (enforce / monitor) as metadata —
|
|
213
|
+
never argument values.
|
|
214
|
+
|
|
215
|
+
## Signed workspace mode
|
|
216
|
+
|
|
217
|
+
The control plane can switch every agent to monitor for a bounded time (the workspace mode). By default an
|
|
218
|
+
SDK takes that switch from the control plane's response over TLS. To accept it only when it is signed, set
|
|
219
|
+
`XTROM_POLICY_VERIFY_KEY` (the PEM from `GET /v1/signing-keys`, or a path to it) and `XTROM_TENANT`, and
|
|
220
|
+
install `xtrom-sdk[update]` for ES256. The SDK then honours monitor only from a directive signed with that
|
|
221
|
+
key, for that workspace, and no older than the last one it accepted; anything else means enforce.
|
|
222
|
+
|
|
223
|
+
## Heartbeat (enforcement liveness)
|
|
224
|
+
`DecisionReporter` sends a `heartbeat` every `heartbeat_interval` seconds (default 60; `0`
|
|
225
|
+
disables) — even when the agent is idle — carrying only instance id, SDK version, mode, policy
|
|
226
|
+
version, per-verdict counts, p50/p95/p99 latency, events dropped since the previous beat, and up
|
|
227
|
+
to 200 identity names for the window (`identities_truncated: true` when more were seen).
|
|
228
|
+
The control plane stamps it on its own clock, so the console's **Enforcement health** screen can
|
|
229
|
+
tell "no attacks" apart from "enforcement stopped running" (`GET /v1/mediator-health`).
|
|
230
|
+
Each decision carries the reporter's random per-process `stream` and a `seq` counted from 1, and
|
|
231
|
+
the heartbeat adds `last_seq` and `dropped_total`, so the console also flags decisions that were
|
|
232
|
+
made but never arrived and weren't reported as dropped.
|
|
233
|
+
Heartbeats are never metered. Use an **agent**-kind enrollment token for the SDK: the control plane
|
|
234
|
+
labels the beat with the token kind, and agent tokens cannot impersonate a gateway/MCP proxy or
|
|
235
|
+
send MCP tool inventories.
|
|
236
|
+
|
|
237
|
+
## Version handshake (P2 hardening)
|
|
238
|
+
`xtrom_headers()` returns the headers every HTTP integration should send:
|
|
239
|
+
`X-Xtrom-API-Version` (contract), `X-Xtrom-SDK-Version` (build), `X-Xtrom-SDK-Lang: python`.
|
|
240
|
+
Unknown API version → 400 pre-auth on the server, so misconfigured clients fail loud.
|
|
241
|
+
|
|
242
|
+
## Status
|
|
243
|
+
Built and tested against `xtrom-engine` (v0.1). The core `Session` decorator, local coding-agent
|
|
244
|
+
hooks, reporter, heartbeat, and first framework adapters are implemented in this package.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# xtrom-sdk-python ✅ built & tested (6/6)
|
|
2
|
+
|
|
3
|
+
Thin Python SDK / middleware that wraps agent frameworks (LangGraph, CrewAI, Bedrock Agents,
|
|
4
|
+
LlamaIndex) and enforces via `xtrom-engine`. For teams that want in-process enforcement
|
|
5
|
+
without running the gateway.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
```bash
|
|
9
|
+
pip install xtrom-sdk --no-index --find-links https://console.xtrom.ai/pkgs/index.html
|
|
10
|
+
```
|
|
11
|
+
The SDK is self-hosted, not on PyPI. Each deploy builds the `xtrom-sdk` and `xtrom-engine` wheels
|
|
12
|
+
into the console's `/pkgs/` page, and **Govern › Connect** shows this line for your environment.
|
|
13
|
+
Public PyPI/npm publishing is opt-in (`PUBLISH_SDK=true` in `.github/workflows/publish.yml`).
|
|
14
|
+
|
|
15
|
+
> **Windows / `pip install --user`:** if `xtrom` prints *"not recognized as a command"*, the
|
|
16
|
+
> per-user Scripts dir (e.g. `%APPDATA%\Python\Python3xx\Scripts`) isn't on PATH — pip warns about
|
|
17
|
+
> this at install time. Run the CLI as a module instead; it's identical to the `xtrom` launcher.
|
|
18
|
+
> Use `py` (the python.org launcher); if you don't have it, swap in `python`:
|
|
19
|
+
> ```bash
|
|
20
|
+
> py -m xtrom_sdk install --url https://api.xtrom.ai --token-stdin
|
|
21
|
+
> ```
|
|
22
|
+
|
|
23
|
+
`--token-stdin` keeps the token out of argv and shell history — paste it at the hidden prompt, or
|
|
24
|
+
set `XTROM_INSTALL_TOKEN` (CI). `--token <TOKEN>` still works for throwaway scripts.
|
|
25
|
+
|
|
26
|
+
## Protect your local coding agent
|
|
27
|
+
Xtrom protects your coding agents locally through each agent's official command hooks. One
|
|
28
|
+
decision engine serves them all; a small adapter per agent (`xtrom_sdk/local/agents.py`) speaks
|
|
29
|
+
that agent's hook protocol.
|
|
30
|
+
|
|
31
|
+
No account needed: decisions are made on this machine and nothing is sent anywhere.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pipx install xtrom # or: uvx xtrom install (`xtrom` is the short name for xtrom-sdk)
|
|
35
|
+
xtrom install # every coding agent found on this machine, user scope
|
|
36
|
+
xtrom install --agent cursor,codex # or pick: claude (claude-code), copilot, cursor, codex, gemini, windsurf, all
|
|
37
|
+
xtrom install --project # this repo only
|
|
38
|
+
xtrom install --monitor # observe and audit, never deny
|
|
39
|
+
xtrom log # what Xtrom stopped (--all for everything, --since 2h, --json)
|
|
40
|
+
xtrom status # what's protected (--json for scripts); --agent narrows it
|
|
41
|
+
xtrom connect --url https://api.xtrom.ai --token-stdin # optional: report to your team's console (--off stops)
|
|
42
|
+
xtrom uninstall
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Agent | `--agent` | Hook config (user · `--project`) | "ask" verdict |
|
|
46
|
+
|---|---|---|---|
|
|
47
|
+
| Claude Code | `claude` | `~/.claude/settings.json` · `.claude/settings.json` | asks you |
|
|
48
|
+
| GitHub Copilot CLI | `copilot` | `~/.copilot/hooks/xtrom.json` · `.github/hooks/xtrom.json` | asks you |
|
|
49
|
+
| Cursor | `cursor` | `~/.cursor/hooks.json` · `.cursor/hooks.json` | blocked¹ |
|
|
50
|
+
| OpenAI Codex CLI | `codex` | `~/.codex/hooks.json` · `.codex/hooks.json` | blocked¹ |
|
|
51
|
+
| Gemini CLI | `gemini` | `~/.gemini/settings.json` · `.gemini/settings.json` | blocked¹ |
|
|
52
|
+
| Windsurf | `windsurf` | `~/.codeium/windsurf/hooks.json` · `.devin/hooks.json` | blocked¹ |
|
|
53
|
+
|
|
54
|
+
¹ These agents' hooks can't pause for a human, so Xtrom fails closed: the call is blocked and the
|
|
55
|
+
reason tells you to run it yourself in a terminal if you meant it. Codex asks you to trust new
|
|
56
|
+
hooks once: open Codex and approve Xtrom in `/hooks`. Windsurf has no web-fetch hook, so its
|
|
57
|
+
untrusted-input signal comes from MCP tools and `curl`/`gh` output.
|
|
58
|
+
|
|
59
|
+
The hook registers for each agent's before-tool and after-tool events. Web results, every MCP tool's output, and
|
|
60
|
+
`curl`/`gh` output are marked as untrusted session context. After that, any shell command that
|
|
61
|
+
isn't recognised local dev work asks you. Writes to `~/.xtrom` are always denied, and changes to
|
|
62
|
+
any coding agent's hook or permission settings always ask. Later sinks such as file writes, shell commands, git pushes, and
|
|
63
|
+
outbound MCP tools are adjudicated by `xtrom-engine`. `BLOCK` becomes the agent's deny,
|
|
64
|
+
`STEP_UP` asks you (or blocks, where the agent can't ask), and `ALLOW` stays silent. Hook processes are short-lived, so Xtrom persists
|
|
65
|
+
only metadata taint state under `~/.xtrom/local/sessions/` and appends a metadata-only audit line
|
|
66
|
+
to `~/.xtrom/local/audit.jsonl` (tool name, verdict, reason code, taint origins, timestamp,
|
|
67
|
+
session id; no raw tool arguments). If state is corrupt or unreadable, Xtrom fails safe: it asks
|
|
68
|
+
before sink tools and stays silent for non-sinks.
|
|
69
|
+
|
|
70
|
+
**Reporting is decoupled from the short-lived hook.** When reporting is configured, each decision is
|
|
71
|
+
written to a local spool and a single **detached background shipper** process delivers it to your
|
|
72
|
+
console with retry/backoff — the hook never blocks a tool call on the network, and an undelivered
|
|
73
|
+
event survives the hook exiting (durable spool, redelivered on the next run). The shipper also emits a
|
|
74
|
+
liveness **heartbeat** so the console's Enforcement-health view shows the agent as live rather than
|
|
75
|
+
silent. Cross-platform: the shipper is spawned detached (POSIX `start_new_session` / Windows
|
|
76
|
+
`DETACHED_PROCESS`) and outlives the agent that started it.
|
|
77
|
+
|
|
78
|
+
**Updating (one-time refresh, then self-updating).** An agent already installed keeps running its
|
|
79
|
+
current version until refreshed **once** — `pip install -U xtrom-sdk --find-links <console>/pkgs/index.html`
|
|
80
|
+
then `xtrom install`. After that, signed updates self-apply per your console policy (approve/auto),
|
|
81
|
+
no manual command. (The very first update can't self-deliver: an old agent doesn't yet have the
|
|
82
|
+
background shipper that applies updates.)
|
|
83
|
+
|
|
84
|
+
Every agent runs the hook through a `/bin/sh` launcher. If this Python disappears or the hook
|
|
85
|
+
crashes, the launcher exits 2, which every supported agent treats as a block, so the call is
|
|
86
|
+
stopped rather than run unchecked. To fix it, re-run
|
|
87
|
+
`xtrom install` or `xtrom uninstall` from a terminal. `--url`/`--token` are stored 0600 in
|
|
88
|
+
`~/.xtrom/local/config.json`, never in your shell profile, where the agent could read them. Only
|
|
89
|
+
`https://` is accepted, except for localhost.
|
|
90
|
+
|
|
91
|
+
**Browser agents.** Browser automation runs through the Playwright, Puppeteer, Chrome DevTools,
|
|
92
|
+
Browserbase/Stagehand and Claude in Chrome MCP servers, and Anthropic's `computer` tool. Every page
|
|
93
|
+
the agent reads, including screenshots, marks the session untrusted. Xtrom then gates the moments
|
|
94
|
+
that have consequences, not every click:
|
|
95
|
+
|
|
96
|
+
| Browser action | Clean session | After untrusted content |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| Snapshot, screenshot, scroll, hover, typing into a field, ordinary clicks | allowed | allowed |
|
|
99
|
+
| Submit: `submit`/Enter, accepting a dialog, clicking Send/Pay/Delete/Sign in…, the first click after typing | allowed | **ask** |
|
|
100
|
+
| Navigate to a URL | allowed | **ask** |
|
|
101
|
+
| Run script in the page (`evaluate`, `run_code`), install extensions, mock routes; upload files | allowed | **ask** |
|
|
102
|
+
| Read or change cookies, localStorage or sessionStorage (including via script) | **ask** | **ask** |
|
|
103
|
+
| Type a secret (API key, token) into a page | **ask** | **deny** |
|
|
104
|
+
| Navigate to a URL carrying a secret; upload a credential file (`~/.ssh/id_rsa`, `.env`) | **deny** | **deny** |
|
|
105
|
+
|
|
106
|
+
The click-after-typing rule exists because a button's label is whatever the page or the model calls
|
|
107
|
+
it. Once data has been entered, the next click may be the one that sends it.
|
|
108
|
+
|
|
109
|
+
**What it is, and isn't.** This is a guardrail inside your coding agent, not a sandbox. It sees each
|
|
110
|
+
tool call the agent reports to its hooks and judges it from the command text. Known limits:
|
|
111
|
+
- In a session that hasn't read untrusted content, ordinary shell commands run without a prompt.
|
|
112
|
+
The hook assumes the agent's own instructions came from you.
|
|
113
|
+
- `npm test`, `make` and `npm run` stay silent after untrusted input, but they run code the agent
|
|
114
|
+
may have edited.
|
|
115
|
+
- A command's text isn't its behaviour. After untrusted input, anything not on the local-dev
|
|
116
|
+
allowlist asks you; a cleverly disguised command can still look harmless to you.
|
|
117
|
+
|
|
118
|
+
For real isolation, pair it with your agent's sandboxing and permission rules.
|
|
119
|
+
|
|
120
|
+
`xtrom discover` inventories MCP servers from common Claude, Cursor, Codex, and VS Code config
|
|
121
|
+
files and flags remote URLs or secret-looking env key names without printing secret values.
|
|
122
|
+
|
|
123
|
+
## In-process SDK and framework adapters
|
|
124
|
+
```python
|
|
125
|
+
from xtrom_sdk import Session
|
|
126
|
+
from xtrom_sdk.adapters import wrap_openai_tools, wrap_langchain_tool
|
|
127
|
+
|
|
128
|
+
session = Session("svc-support-bot")
|
|
129
|
+
|
|
130
|
+
def read_web(url: str) -> str: ...
|
|
131
|
+
def http_post(url: str, body: str) -> str: ...
|
|
132
|
+
|
|
133
|
+
dispatch = wrap_openai_tools(
|
|
134
|
+
session,
|
|
135
|
+
{"read_web": read_web, "http_post": http_post},
|
|
136
|
+
sources={"read_web"}, # output is untrusted ingress
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
tool_message = dispatch({
|
|
140
|
+
"id": "call_1",
|
|
141
|
+
"function": {"name": "read_web", "arguments": "{\"url\":\"https://docs.example\"}"},
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
safe_langchain_tool = wrap_langchain_tool(session, existing_tool, sources={"retriever"})
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Adapters in `xtrom_sdk.adapters`:
|
|
148
|
+
|
|
149
|
+
- `wrap_openai_tools(session, tools, *, sources=...)` returns a dispatcher for OpenAI Chat
|
|
150
|
+
Completions / Responses tool calls. It parses the tool name and JSON arguments, adjudicates
|
|
151
|
+
through `Session` before execution, runs only on `ALLOW`, and returns a tool message. `BLOCK`
|
|
152
|
+
and `STEP_UP` return structured JSON content for the model instead of running the tool.
|
|
153
|
+
- `wrap_anthropic_tools(session, tools, *, sources=...)` does the same for Anthropic Messages
|
|
154
|
+
`tool_use` blocks and returns `tool_result` blocks.
|
|
155
|
+
- `wrap_langchain_tool(session, tool, ...)` wraps a LangChain/LangGraph-style tool by duck type
|
|
156
|
+
(`.name`, `.invoke` / `._run`) and preserves the callable interface.
|
|
157
|
+
- `wrap_crewai_tool(session, tool, ...)` wraps a CrewAI-style tool by duck type (`.name`,
|
|
158
|
+
`._run` / `.run`).
|
|
159
|
+
|
|
160
|
+
Framework packages are not hard dependencies; imports are lazy/duck-typed so the SDK imports
|
|
161
|
+
without OpenAI, Anthropic, LangChain, LangGraph, or CrewAI installed. Adapter tests use minimal
|
|
162
|
+
fake framework objects. Live framework CI is not wired yet; the supported contract is the stable
|
|
163
|
+
tool-call/tool object shape above.
|
|
164
|
+
|
|
165
|
+
## Session taint (on by default)
|
|
166
|
+
Once an agent reads untrusted content (a web page, an MCP tool result, an email), the model's
|
|
167
|
+
context is influenced even if the attacker's text is *paraphrased* before it reaches a sink.
|
|
168
|
+
`Session` therefore tracks two tiers of taint:
|
|
169
|
+
|
|
170
|
+
- **Value taint** (proven): untrusted bytes reach a sink argument → `BLOCK` (L3).
|
|
171
|
+
- **Context taint** (inferred): any sensitive sink after untrusted ingress in the same session → `STEP_UP`
|
|
172
|
+
(human approval), never a silent allow. It lasts for the whole `Session`: the model can carry a
|
|
173
|
+
reworded copy of untrusted content into a later task, so `new_task()` does not clear it.
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
s = Session("svc-support-bot") # session_taint=True by default
|
|
177
|
+
s.context_tainted # True after the first untrusted ingress
|
|
178
|
+
Session("svc-support-bot") # a genuinely fresh conversation: a new Session
|
|
179
|
+
Session("batch-bot", session_taint=False) # opt out (e.g. no untrusted inputs at all)
|
|
180
|
+
```
|
|
181
|
+
`@s.guard(source=True)` marks where a tool's *output* goes, not what the tool can do, so source
|
|
182
|
+
tools get no special exemption from context taint. Read-only tools (rated `LOW` in the policy,
|
|
183
|
+
e.g. `read_file`) are never held; a dual-use tool such as `execute_sql` or a generic MCP call is,
|
|
184
|
+
because a reworded write through it is exactly what context taint exists to catch. Rate genuine
|
|
185
|
+
read-only tools `LOW`; fetches to allowlisted hosts are fine. Tools in `Policy.context_taint_exempt`
|
|
186
|
+
are the explicit, auditable opt-out (e.g. a browsing agent). Every decision
|
|
187
|
+
shipped to the control plane carries `session_id` and `mode` (enforce / monitor) as metadata —
|
|
188
|
+
never argument values.
|
|
189
|
+
|
|
190
|
+
## Signed workspace mode
|
|
191
|
+
|
|
192
|
+
The control plane can switch every agent to monitor for a bounded time (the workspace mode). By default an
|
|
193
|
+
SDK takes that switch from the control plane's response over TLS. To accept it only when it is signed, set
|
|
194
|
+
`XTROM_POLICY_VERIFY_KEY` (the PEM from `GET /v1/signing-keys`, or a path to it) and `XTROM_TENANT`, and
|
|
195
|
+
install `xtrom-sdk[update]` for ES256. The SDK then honours monitor only from a directive signed with that
|
|
196
|
+
key, for that workspace, and no older than the last one it accepted; anything else means enforce.
|
|
197
|
+
|
|
198
|
+
## Heartbeat (enforcement liveness)
|
|
199
|
+
`DecisionReporter` sends a `heartbeat` every `heartbeat_interval` seconds (default 60; `0`
|
|
200
|
+
disables) — even when the agent is idle — carrying only instance id, SDK version, mode, policy
|
|
201
|
+
version, per-verdict counts, p50/p95/p99 latency, events dropped since the previous beat, and up
|
|
202
|
+
to 200 identity names for the window (`identities_truncated: true` when more were seen).
|
|
203
|
+
The control plane stamps it on its own clock, so the console's **Enforcement health** screen can
|
|
204
|
+
tell "no attacks" apart from "enforcement stopped running" (`GET /v1/mediator-health`).
|
|
205
|
+
Each decision carries the reporter's random per-process `stream` and a `seq` counted from 1, and
|
|
206
|
+
the heartbeat adds `last_seq` and `dropped_total`, so the console also flags decisions that were
|
|
207
|
+
made but never arrived and weren't reported as dropped.
|
|
208
|
+
Heartbeats are never metered. Use an **agent**-kind enrollment token for the SDK: the control plane
|
|
209
|
+
labels the beat with the token kind, and agent tokens cannot impersonate a gateway/MCP proxy or
|
|
210
|
+
send MCP tool inventories.
|
|
211
|
+
|
|
212
|
+
## Version handshake (P2 hardening)
|
|
213
|
+
`xtrom_headers()` returns the headers every HTTP integration should send:
|
|
214
|
+
`X-Xtrom-API-Version` (contract), `X-Xtrom-SDK-Version` (build), `X-Xtrom-SDK-Lang: python`.
|
|
215
|
+
Unknown API version → 400 pre-auth on the server, so misconfigured clients fail loud.
|
|
216
|
+
|
|
217
|
+
## Status
|
|
218
|
+
Built and tested against `xtrom-engine` (v0.1). The core `Session` decorator, local coding-agent
|
|
219
|
+
hooks, reporter, heartbeat, and first framework adapters are implemented in this package.
|