Skip to main content

xtrom-sdk

Python SDK for Xtrom, the deterministic runtime firewall for AI agents. It wraps agent tools and frameworks (LangGraph, CrewAI, Bedrock Agents, LlamaIndex) and enforces in-process via xtrom-engine, and it ships the xtrom command that protects coding agents on a developer's machine.

Install

pip install xtrom-sdk          # the SDK, for your own agents
pipx install xtrom             # or just the `xtrom` command for your coding agents (also: uvx xtrom install)

Releases are published from Xtrom's release workflow by trusted publishing, each with a PyPI attestation. Air-gapped or pinned installs use your console's copy of the same builds: pip install xtrom-sdk --no-index --find-links https://console.xtrom.ai/pkgs/index.html (SHA-256 pinned).

Windows / pip install --user: if xtrom prints "not recognized as a command", the per-user Scripts dir (e.g. %APPDATA%\Python\Python3xx\Scripts) isn't on PATH — pip warns about this at install time. Run the CLI as a module instead; it's identical to the xtrom launcher. Use py (the python.org launcher); if you don't have it, swap in python:

py -m xtrom_sdk install --url https://api.xtrom.ai --token-stdin

--token-stdin keeps the token out of argv and shell history — paste it at the hidden prompt, or set XTROM_INSTALL_TOKEN (CI). --token <TOKEN> still works for throwaway scripts.

Protect your local coding agent

Xtrom protects your coding agents locally through each agent's official command hooks. One decision engine serves them all; a small adapter per agent (xtrom_sdk/local/agents.py) speaks that agent's hook protocol.

No account needed: decisions are made on this machine and nothing is sent anywhere.

pipx install xtrom               # or: uvx xtrom install  (`xtrom` is the short name for xtrom-sdk)
xtrom install                    # every coding agent found on this machine, user scope
xtrom install --agent cursor,codex   # or pick: claude (claude-code), copilot, cursor, codex, gemini, windsurf, all
xtrom install --project          # this repo only
xtrom install --monitor          # observe and audit, never deny
xtrom log                        # what Xtrom stopped (--all for everything, --since 2h, --json)
xtrom status                     # what's protected (--json for scripts); --agent narrows it
xtrom connect --url https://api.xtrom.ai --token-stdin    # optional: report to your team's console (--off stops)
xtrom uninstall
Agent --agent Hook config (user · --project) "ask" verdict
Claude Code claude ~/.claude/settings.json · .claude/settings.json asks you
GitHub Copilot CLI copilot ~/.copilot/hooks/xtrom.json · .github/hooks/xtrom.json asks you
Cursor cursor ~/.cursor/hooks.json · .cursor/hooks.json blocked¹
OpenAI Codex CLI codex ~/.codex/hooks.json · .codex/hooks.json blocked¹
Gemini CLI gemini ~/.gemini/settings.json · .gemini/settings.json blocked¹
Windsurf windsurf ~/.codeium/windsurf/hooks.json · .devin/hooks.json blocked¹

¹ These agents' hooks can't pause for a human, so Xtrom fails closed: the call is blocked and the reason tells you to run it yourself in a terminal if you meant it. Codex asks you to trust new hooks once: open Codex and approve Xtrom in /hooks. Windsurf has no web-fetch hook, so its untrusted-input signal comes from MCP tools and curl/gh output.

The hook registers for each agent's before-tool and after-tool events. Web results, every MCP tool's output, and curl/gh output are marked as untrusted session context. After that, any shell command that isn't recognised local dev work asks you. Writes to ~/.xtrom are always denied, and changes to any coding agent's hook or permission settings always ask. Later sinks such as file writes, shell commands, git pushes, and outbound MCP tools are adjudicated by xtrom-engine. BLOCK becomes the agent's deny, STEP_UP asks you (or blocks, where the agent can't ask), and ALLOW stays silent. Hook processes are short-lived, so Xtrom persists only metadata taint state under ~/.xtrom/local/sessions/ and appends a metadata-only audit line to ~/.xtrom/local/audit.jsonl (tool name, verdict, reason code, taint origins, timestamp, session id; no raw tool arguments). If state is corrupt or unreadable, Xtrom fails safe: it asks before sink tools and stays silent for non-sinks.

Reporting is decoupled from the short-lived hook. When reporting is configured, each decision is written to a local spool and a single detached background shipper process delivers it to your console with retry/backoff — the hook never blocks a tool call on the network, and an undelivered event survives the hook exiting (durable spool, redelivered on the next run). The shipper also emits a liveness heartbeat so the console's Enforcement-health view shows the agent as live rather than silent. Cross-platform: the shipper is spawned detached (POSIX start_new_session / Windows DETACHED_PROCESS) and outlives the agent that started it.

Updating (one-time refresh, then self-updating). An agent already installed keeps running its current version until refreshed once — pip install -U xtrom-sdk --find-links <console>/pkgs/index.html then xtrom install. After that, signed updates self-apply per your console policy (approve/auto), no manual command. (The very first update can't self-deliver: an old agent doesn't yet have the background shipper that applies updates.)

Every agent runs the hook through a /bin/sh launcher. If this Python disappears or the hook crashes, the launcher exits 2, which every supported agent treats as a block, so the call is stopped rather than run unchecked. To fix it, re-run xtrom install or xtrom uninstall from a terminal. --url/--token are stored 0600 in ~/.xtrom/local/config.json, never in your shell profile, where the agent could read them. Only https:// is accepted, except for localhost.

Browser agents. Browser automation runs through the Playwright, Puppeteer, Chrome DevTools, Browserbase/Stagehand and Claude in Chrome MCP servers, and Anthropic's computer tool. Every page the agent reads, including screenshots, marks the session untrusted. Xtrom then gates the moments that have consequences, not every click:

Browser action Clean session After untrusted content
Snapshot, screenshot, scroll, hover, typing into a field, ordinary clicks allowed allowed
Submit: submit/Enter, accepting a dialog, clicking Send/Pay/Delete/Sign in…, the first click after typing allowed ask
Navigate to a URL allowed ask
Run script in the page (evaluate, run_code), install extensions, mock routes; upload files allowed ask
Read or change cookies, localStorage or sessionStorage (including via script) ask ask
Type a secret (API key, token) into a page ask deny
Navigate to a URL carrying a secret; upload a credential file (~/.ssh/id_rsa, .env) deny deny

The click-after-typing rule exists because a button's label is whatever the page or the model calls it. Once data has been entered, the next click may be the one that sends it.

What it is, and isn't. This is a guardrail inside your coding agent, not a sandbox. It sees each tool call the agent reports to its hooks and judges it from the command text. Known limits:

  • In a session that hasn't read untrusted content, ordinary shell commands run without a prompt. The hook assumes the agent's own instructions came from you.
  • npm test, make and npm run stay silent after untrusted input, but they run code the agent may have edited.
  • A command's text isn't its behaviour. After untrusted input, anything not on the local-dev allowlist asks you; a cleverly disguised command can still look harmless to you.

For real isolation, pair it with your agent's sandboxing and permission rules.

xtrom discover inventories MCP servers from common Claude, Cursor, Codex, and VS Code config files and flags remote URLs or secret-looking env key names without printing secret values.

In-process SDK and framework adapters

from xtrom_sdk import Session
from xtrom_sdk.adapters import wrap_openai_tools, wrap_langchain_tool

session = Session("svc-support-bot")

def read_web(url: str) -> str: ...
def http_post(url: str, body: str) -> str: ...

dispatch = wrap_openai_tools(
    session,
    {"read_web": read_web, "http_post": http_post},
    sources={"read_web"},                  # output is untrusted ingress
)

tool_message = dispatch({
    "id": "call_1",
    "function": {"name": "read_web", "arguments": "{\"url\":\"https://docs.example\"}"},
})

safe_langchain_tool = wrap_langchain_tool(session, existing_tool, sources={"retriever"})

Adapters in xtrom_sdk.adapters:

  • wrap_openai_tools(session, tools, *, sources=...) returns a dispatcher for OpenAI Chat Completions / Responses tool calls. It parses the tool name and JSON arguments, adjudicates through Session before execution, runs only on ALLOW, and returns a tool message. BLOCK and STEP_UP return structured JSON content for the model instead of running the tool.
  • wrap_anthropic_tools(session, tools, *, sources=...) does the same for Anthropic Messages tool_use blocks and returns tool_result blocks.
  • wrap_langchain_tool(session, tool, ...) wraps a LangChain/LangGraph-style tool by duck type (.name, .invoke / ._run) and preserves the callable interface.
  • wrap_crewai_tool(session, tool, ...) wraps a CrewAI-style tool by duck type (.name, ._run / .run).

Framework packages are not hard dependencies; imports are lazy/duck-typed so the SDK imports without OpenAI, Anthropic, LangChain, LangGraph, or CrewAI installed. Adapter tests use minimal fake framework objects. Live framework CI is not wired yet; the supported contract is the stable tool-call/tool object shape above.

Session taint (on by default)

Once an agent reads untrusted content (a web page, an MCP tool result, an email), the model's context is influenced even if the attacker's text is paraphrased before it reaches a sink. Session therefore tracks two tiers of taint:

  • Value taint (proven): untrusted bytes reach a sink argument → BLOCK (L3).
  • Context taint (inferred): any sensitive sink after untrusted ingress in the same session → STEP_UP (human approval), never a silent allow. It lasts for the whole Session: the model can carry a reworded copy of untrusted content into a later task, so new_task() does not clear it.
s = Session("svc-support-bot")              # session_taint=True by default
s.context_tainted                            # True after the first untrusted ingress
Session("svc-support-bot")                   # a genuinely fresh conversation: a new Session
Session("batch-bot", session_taint=False)    # opt out (e.g. no untrusted inputs at all)

@s.guard(source=True) marks where a tool's output goes, not what the tool can do, so source tools get no special exemption from context taint. Read-only tools (rated LOW in the policy, e.g. read_file) are never held; a dual-use tool such as execute_sql or a generic MCP call is, because a reworded write through it is exactly what context taint exists to catch. Rate genuine read-only tools LOW; fetches to allowlisted hosts are fine. Tools in Policy.context_taint_exempt are the explicit, auditable opt-out (e.g. a browsing agent). Every decision shipped to the control plane carries session_id and mode (enforce / monitor) as metadata — never argument values.

Signed workspace mode

The control plane can switch every agent to monitor for a bounded time (the workspace mode). By default an SDK takes that switch from the control plane's response over TLS. To accept it only when it is signed, set XTROM_POLICY_VERIFY_KEY (the PEM from GET /v1/signing-keys, or a path to it) and XTROM_TENANT, and install xtrom-sdk[update] for ES256. The SDK then honours monitor only from a directive signed with that key, for that workspace, and no older than the last one it accepted; anything else means enforce.

Heartbeat (enforcement liveness)

DecisionReporter sends a heartbeat every heartbeat_interval seconds (default 60; 0 disables) — even when the agent is idle — carrying only instance id, SDK version, mode, policy version, per-verdict counts, p50/p95/p99 latency, events dropped since the previous beat, and up to 200 identity names for the window (identities_truncated: true when more were seen). The control plane stamps it on its own clock, so the console's Enforcement health screen can tell "no attacks" apart from "enforcement stopped running" (GET /v1/mediator-health). Each decision carries the reporter's random per-process stream and a seq counted from 1, and the heartbeat adds last_seq and dropped_total, so the console also flags decisions that were made but never arrived and weren't reported as dropped. Heartbeats are never metered. Use an agent-kind enrollment token for the SDK: the control plane labels the beat with the token kind, and agent tokens cannot impersonate a gateway/MCP proxy or send MCP tool inventories.

Version handshake (P2 hardening)

xtrom_headers() returns the headers every HTTP integration should send: X-Xtrom-API-Version (contract), X-Xtrom-SDK-Version (build), X-Xtrom-SDK-Lang: python. Unknown API version → 400 pre-auth on the server, so misconfigured clients fail loud.

Status

Built and tested against xtrom-engine (v0.1). The core Session decorator, local coding-agent hooks, reporter, heartbeat, and first framework adapters are implemented in this package.

Metadata

Release files for xtrom-sdk 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xtrom-sdk 0.5.2
File Size Uploaded Provenance Actions
xtrom_sdk-0.5.2.tar.gz 122.1 kB With provenance Details for xtrom_sdk-0.5.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xtrom-sdk 0.5.2
File Interpreter ABI Platform Actions
xtrom_sdk-0.5.2-py3-none-any.whl Python 3 none any Details for xtrom_sdk-0.5.2-py3-none-any.whl

Total release size: 219.1 kB

Release files / xtrom_sdk-0.5.2.tar.gz

Download URL xtrom_sdk-0.5.2.tar.gz
Size 122.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7d33efb3139b66122821f5869f30769ddc6131d61b42b4bad2668f3c710ce066
BLAKE2b-256 checksum
How to use checksums
b129788293fc695da1e839ae16cba13a8819230a58f7ccae9401ec86d910c5bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / xtrom_sdk-0.5.2-py3-none-any.whl

Download URL xtrom_sdk-0.5.2-py3-none-any.whl
Size 97.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21cac3b7083f5d18fa2df625c8e9c7a5710d69e0ac8eb1ca72706da6bf382e4e
BLAKE2b-256 checksum
How to use checksums
9dd28b8cb302a1d6aee7eaa9baafa3c401881c8c785a38ee6064e4b284fc0b7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for xtrom-sdk 0.5.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for xtrom_sdk-0.5.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page