Python SDK for Sleigh runtime server.
Project description
Sleigh Python SDK
Python SDK for the Sleigh runtime server.
Two client variants are included:
- LangChain Tool variant: one-call
as_langchain_tool()(returnsStructuredTool) - MCP variant: expose runtime APIs as MCP tools over stdio
1. Install
pip install .
Optional extras:
pip install ".[langchain]"
pip install ".[mcp]"
2. Base Python Client
from sdk import SleighClient
client = SleighClient(base_url="http://127.0.0.1:8080")
session_token = "sess_demo"
created = client.create_sandbox(session_token=session_token, image="alpine:3.20")
sandbox_id = created["id"]
3. Ordered Workflow (AI Coding)
Run multiple steps in one request and stop early on failure/timeout:
result = client.run_workflow(
session_token=session_token,
steps=[
{"action": "create_sandbox", "image": "alpine:3.20", "memory_limit_mb": 512},
{"action": "exec_command", "command": "echo hello", "wait": True, "wait_timeout_seconds": 10},
{"action": "create_snapshot"},
{"action": "exec_command", "command": "uname -a", "wait": True},
],
)
print(result["stopped_early"], result["steps"])
4. Sandbox Read API (AI Coding)
read_result = client.read_sandbox(
session_token=session_token,
sandbox_id=sandbox_id,
command="rg",
args=["TODO", "/workspace"],
timeout_seconds=10,
max_output_bytes=65536,
max_lines=200,
)
print(read_result)
5. Patch API (Sandbox Semantic)
patch_workspace targets:
POST /sandboxes/{id}/ops/patch- validates sandbox auth + mounted workspace path ownership
result = client.patch_workspace(
session_token=session_token,
sandbox_id=sandbox_id,
cwd="/home/hxluo/sleigh_env",
patch="*** Begin Patch\n*** End Patch\n",
)
6. Low-Memory Create Guard
When host available memory ratio:
< 5%: create is blocked>= 5%and< 8%: create requiresconfirm_low_memory=True
created = client.create_sandbox(
session_token=session_token,
image="alpine:3.20",
confirm_low_memory=True,
)
7. More Examples
- LangChain integration:
../README_langchain.md - MCP integration:
../README_mcp.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sleigh_sdk-0.1.0.tar.gz
(2.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sleigh_sdk-0.1.0.tar.gz.
File metadata
- Download URL: sleigh_sdk-0.1.0.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39b14fcf3a164920458a67911c33b18a3c5dc1f27e65ef5d396a8c9c6195b749
|
|
| MD5 |
7576e6fdeba9272fc9bb2d7861896061
|
|
| BLAKE2b-256 |
36b19ef65ec35de1797a31f6267c6346d81535fe0de23df946ec88e48794bcd4
|
File details
Details for the file sleigh_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sleigh_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9c882e3e1eebbb6304ab24ef6e0c1d9463b1adb30e6d8595438142773eeb458
|
|
| MD5 |
4872e6ca9cfd74a15face45729a06924
|
|
| BLAKE2b-256 |
faf40a00a5270bffeb8465259c8a4036aa2330a56707e5db9005997713f9acae
|