Metadata-Version: 2.5
Name: securespace
Version: 0.2.0
Summary: Send your Python agent's calls through the SecureSpace Gateway, and handle its decisions.
Project-URL: Homepage, https://securespace.club
License: Copyright (c) 2026 SecureSpace. All rights reserved.
        
        This software is provided to connect to the SecureSpace service and may be used
        only for that purpose, under the SecureSpace Terms of Service:
        https://securespace.club/legal/terms
        
        You may not modify, reverse engineer, redistribute or sublicense it except as
        those terms allow.
License-File: LICENSE
Keywords: ai-agents,gateway,policy,security
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# SecureSpace SDK for Python

Send your agent's calls to outside services through the SecureSpace Gateway. Each
call is checked against your organization's rules, and blocked calls come back
as a value you can handle, never a silent failure. Standard library only.

You need a SecureSpace account and an agent key: sign up at
https://securespace.club, then create an agent in the console.

```bash
pip install securespace
```

```python
import os
from securespace import SecureSpaceClient

client = SecureSpaceClient("https://gateway.securespace.club", os.environ["SECURESPACE_API_KEY"])

# "crm" is a service registered on the console's Upstreams page.
res = client.get("crm", "/contacts")
if res.blocked:
    print("blocked:", res.error_code)
else:
    print(res.body)
```

## Guard your agent's tools

Wrap a tool so SecureSpace decides before it runs. It works with any framework
that builds tools from plain functions (OpenAI Agents SDK, LangChain, LangGraph,
CrewAI, LlamaIndex), sync or async. Put it under the framework's own decorator,
so the framework still sees the function's arguments and docstring.

```python
import os

from agents import function_tool  # or langchain's @tool, crewai's @tool, ...
from securespace import Guard, SecureSpaceToolBlocked

guard = Guard(
    "https://gateway.securespace.club",
    os.environ["SECURESPACE_API_KEY"],
    namespace="billing",          # rules match this as the destination
)

@function_tool
@guard.tool(declared_verb="transfer")
def refund(order_id: str, amount: int) -> str:
    """Refund an order."""
    ...
```

A refused call raises `SecureSpaceToolBlocked` instead of running. Frameworks can
hand that to the model as a tool error, so the agent learns it was not allowed
(the OpenAI Agents SDK does by default; in LangChain set `handle_tool_error=True`).
When a rule needs approval, the message names the request; once a person
approves, the identical call runs once. Only a hash of the arguments is sent,
never the arguments.

## Send chosen hosts through the Gateway

Route only the hosts you list through the Gateway; everything else goes out
untouched, and your SecureSpace key is never sent to it.

```python
import os

import httpx, requests
from securespace import AddressedRoutes

routes = AddressedRoutes(
    "https://gateway.securespace.club",
    os.environ["SECURESPACE_API_KEY"],
    {"api.stripe.com": "stripe"},  # host -> name registered on the Upstreams page
)

client = httpx.Client(transport=routes.httpx_transport())         # httpx
aclient = httpx.AsyncClient(transport=routes.httpx_async_transport())
session = routes.mount_requests(requests.Session())               # requests
```

Neither `httpx` nor `requests` is required by the SDK; use whichever you have.

Requires Python 3.9 or later.
