Skip to main content

HTTP client and sandbox backend for AstraForge DeepAgent.

Project description

AstraForge Toolkit

Lightweight Python package for using AstraForge DeepAgent and sandboxes from another project.

Contents:

  • astraforge_toolkit.SandboxBackend: DeepAgents backend that executes via the remote AstraForge sandbox API.
  • astraforge_toolkit.DeepAgentClient: HTTP client for DeepAgent conversations, sandbox sessions (create/list/heartbeat/stop/delete), file upload/download/export, and streaming replies.
  • Remote sandbox tools: sandbox_shell, sandbox_python_repl, sandbox_open_url_with_playwright, sandbox_view_image — all execute inside the sandbox via HTTP.

Install

pip install astraforge-toolkit

Quick start

Create a sandbox-backed DeepAgent

from deepagents import create_deep_agent
from langchain_openai import ChatOpenAI
from astraforge_toolkit import (
    SandboxBackend,
    sandbox_shell,
    sandbox_python_repl,
    sandbox_open_url_with_playwright,
    sandbox_view_image,
)

def backend_factory(rt):
    return SandboxBackend(
        rt,
        base_url="https://your.astra.forge/api",
        api_key="your-api-key",
        # optional: session_params={"image": "astraforge/codex-cli:latest"},
    )

model = ChatOpenAI(model="gpt-4o", api_key="...")
agent = create_deep_agent(model=model, backend=backend_factory)

# Optional: register sandbox tools with your agent/tool registry
tools = [sandbox_shell, sandbox_python_repl, sandbox_open_url_with_playwright, sandbox_view_image]

Create a sandbox session (no DeepAgent conversation)

from astraforge_toolkit import DeepAgentClient

client = DeepAgentClient(base_url="https://your.astra.forge/api", api_key="your-api-key")
sandbox = client.create_sandbox_session(session_params={"image": "astraforge/codex-cli:latest"})

# Upload text (or bytes) into the sandbox workspace
client.upload_file(sandbox.session_id, "/workspace/hello.txt", content="hello from toolkit!\n")

# Download the file back; omit encoding to get raw bytes
print(client.get_file_content(sandbox.session_id, "/workspace/hello.txt", encoding="utf-8"))

# Export a file as an artifact (resolves download URL when configured)
artifact = client.export_file(
    sandbox.session_id,
    "/workspace/hello.txt",
    filename="hello.txt",
    content_type="text/plain",
)
print("artifact id:", artifact.artifact_id, "download:", artifact.download_url)

# Keep the sandbox alive or clean it up when finished
client.heartbeat_sandbox_session(sandbox.session_id)
client.stop_sandbox_session(sandbox.session_id)  # or client.delete_sandbox_session(...)

Call DeepAgent over HTTP

from astraforge_toolkit import DeepAgentClient

client = DeepAgentClient(base_url="https://your.astra.forge/api", api_key="your-api-key")
conv = client.create_conversation()

for chunk in client.stream_message(conv.conversation_id, "Hello, sandbox!"):
    print(chunk)

Build & publish

cd astraforge-python-package
python -m build
python -m twine upload dist/*  # or use --repository testpypi

Configure ~/.pypirc or set TWINE_USERNAME=__token__ and TWINE_PASSWORD=<pypi-token> for uploads.

Examples

See examples/local_api_test.ipynb for a quick notebook that exercises the client against a local http://localhost:8001/api instance.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astraforge_toolkit-0.1.8.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astraforge_toolkit-0.1.8-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file astraforge_toolkit-0.1.8.tar.gz.

File metadata

  • Download URL: astraforge_toolkit-0.1.8.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for astraforge_toolkit-0.1.8.tar.gz
Algorithm Hash digest
SHA256 74e0805e39a5f464e628997af5b85728d71a7e2138882b950cb4977543b5b08e
MD5 fde492e162a5d34ae0bbb9dd7d75ca28
BLAKE2b-256 84108716ef2d5f4dad4013aa2f7acc0920339bbbeff8ab5508c756028432a113

See more details on using hashes here.

File details

Details for the file astraforge_toolkit-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for astraforge_toolkit-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f74be1249df01b13f1d9cca2d9e03b9d4c110779710c32e5e7c9bb9ec54a9700
MD5 bdcf48934e79bcd3917668bcdc7c4434
BLAKE2b-256 5977ca1b5d34debe8c4b196cfc1c3b59d64ed5e40859d99cea8b2c0b86f19755

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page