Skip to main content

runtm-shared

Canonical contracts for Runtm: manifest schema, types, errors, and shared utilities.

Installation

pip install runtm-shared

Contents

Core Modules

Module Description
types.py Deployment state machine, enums, session types, API types
manifest.py Pydantic models for runtm.yaml validation
errors.py Typed error hierarchy with recovery hints
ids.py Deterministic deployment ID generation
env.py Environment variable handling and validation

Session & Sandbox Types

Module Description
types.py Session, SessionState, SessionMode, SandboxConfig, AgentType

Discovery & Requests

Module Description
discovery.py Discovery metadata for searchable deployments
requests.py Agent request/proposal handling (runtm.requests.yaml)
lockfiles.py Lockfile validation and drift detection

Infrastructure

Module Description
storage/base.py Abstract storage interface for artifacts
dns/ DNS provider abstraction (Cloudflare)
redis.py Redis connection utilities
urls.py URL generation for deployments
deploy_tracking.py Deployment tracking and state management

Telemetry

Module Description
telemetry/ Anonymous usage telemetry (opt-out available)

Usage

Types and State Machine

from runtm_shared.types import (
    DeploymentState,
    can_transition,
    MachineTier,
    # Session types
    Session,
    SessionState,
    SessionMode,
    SandboxConfig,
    AgentType,
)

# Check if state transition is valid
if can_transition(DeploymentState.BUILDING, DeploymentState.DEPLOYING):
    # proceed with transition
    pass

Manifest Validation

from runtm_shared.manifest import Manifest

# Load and validate runtm.yaml
manifest = Manifest.from_yaml("runtm.yaml")
print(manifest.name, manifest.template, manifest.runtime)

Error Handling

from runtm_shared.errors import (
    RuntmError,
    ManifestValidationError,
    DeploymentError,
    AuthenticationError,
)

try:
    # ... operation
except ManifestValidationError as e:
    print(f"Invalid manifest: {e}")
    print(f"Recovery: {e.recovery_hint}")

ID Generation

from runtm_shared.ids import generate_deployment_id

# Generate deterministic deployment ID
dep_id = generate_deployment_id(project_name="my-api", user_id="usr_123")
# Returns: dep_abc123...

Session Types

from runtm_shared.types import (
    Session,
    SessionState,
    SessionMode,
    AgentType,
    SandboxConfig,
)

# Create a session config
config = SandboxConfig(
    agent=AgentType.CLAUDE_CODE,
    template="backend-service",
)

# Session states
SessionState.RUNNING
SessionState.STOPPED
SessionState.DESTROYED

# Session modes
SessionMode.AUTOPILOT   # Agent controlled via prompts
SessionMode.INTERACTIVE # User controls agent manually

Discovery Metadata

from runtm_shared.discovery import DiscoveryMetadata

# Load discovery metadata
discovery = DiscoveryMetadata.from_yaml("runtm.discovery.yaml")
print(discovery.description)
print(discovery.tags)
print(discovery.capabilities)

Development

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Type checking
mypy runtm_shared

Package Structure

runtm_shared/
├── __init__.py
├── types.py          # Core types and state machine
├── manifest.py       # Manifest schema (Pydantic)
├── errors.py         # Error hierarchy
├── ids.py            # ID generation
├── env.py            # Environment handling
├── discovery.py      # Discovery metadata
├── requests.py       # Agent requests
├── lockfiles.py      # Lockfile validation
├── urls.py           # URL generation
├── redis.py          # Redis utilities
├── deploy_tracking.py # Deployment tracking
├── storage/
│   └── base.py       # Storage interface
├── dns/
│   ├── base.py       # DNS provider interface
│   └── cloudflare.py # Cloudflare implementation
└── telemetry/
    ├── base.py       # Telemetry base
    ├── service.py    # Telemetry service
    └── ...           # Other telemetry modules

Metadata

Release files for runtm-shared 0.2.4

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

Source distribution (sdist)

Source distribution for runtm-shared 0.2.4
File Size Uploaded
runtm_shared-0.2.4.tar.gz 123.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for runtm-shared 0.2.4
File Interpreter ABI Platform
runtm_shared-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 183.5 kB

Release files / runtm_shared-0.2.4.tar.gz

Download URL runtm_shared-0.2.4.tar.gz
Size 123.0 kB
Tags Source
SHA-256 checksum
How to use checksums
92adf5b27387cf0914475dc3a104ce2b879839a7974abba59c6dd12603bc6626
BLAKE2b-256 checksum
How to use checksums
b48c6f500bfe3de78198caff74a7e8cb110977813a7b050dce75496ab38175b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / runtm_shared-0.2.4-py3-none-any.whl

Download URL runtm_shared-0.2.4-py3-none-any.whl
Size 60.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc45cd899e073b8ef8d424f107a163b0aacbc4b54a5d69e8fd1a7296a0a51ebf
BLAKE2b-256 checksum
How to use checksums
5438a740d371b4ed0828992aba07c27b0fe8000cd6f6ae7e6a529cac27619c96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

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