OpenShell Documentation

repository·main·Indexed 27 days ago

https://github.com/nvidia/openshell

OpenShell is a safe, private runtime for autonomous AI agents providing sandboxed execution environments. It utilizes a Gateway control plane and Supervisor data plane to enforce declarative YAML policies governing filesystem, network, process, and inference access. The system includes drivers for Docker and Kubernetes, supporting GPU requests via CDI and PVC mounts, as well as a core library for metadata traits, inference profiles, and middleware contracts.

Tokens
151.6K
Snippets
269
Records
758
Agent score
93%

What's inside OpenShell

  1. Overview of openshell-providers

    main

    The openshell-providers crate is responsible for the discovery and normalization of credentials required by sandboxes at runtime. It isolates provider-specific logic (such as parsing rules and discovery mechanisms) from the main CLI and gateway control flows.

    Key Responsibilities

    • Discovery: Locating local credentials within environment variables and known configuration files.
    • Normalization: Converting discovered data into standardized provider records.
    • Encapsulation: Maintaining provider-specific parsing rules within dedicated provider modules.
    • Security: Ensuring credential values are not logged during the discovery process.

    Architecture Integration

    • The Gateway is responsible for persisting provider records.
    • The Sandbox Supervisor fetches the resolved provider environment from the gateway and injects credentials into agent child processes.
    • The Router handles routing inference requests.
  2. Overview of Multi-Player Support (RFC 0011)

    main

    OpenShell is evolving from a single-player experience to a multi-player model to support enterprise teams, CI/CD orchestration, and compliance requirements. This transition introduces workspaces as hard isolation boundaries to prevent users from seeing each other's sandboxes, credentials, and activity.

    Key features of the multi-player design include:

    • Workspaces: Provide isolation and scoping for resources.
    • Expanded Role Model: Includes Platform Admin, Workspace Admin, and User roles.
    • Workspace-scoped Access: Permissions and visibility are restricted to specific workspaces.
    • Quota Enforcement: Per-workspace resource limits.
    • Audit Trails: Enhanced attribution of sandbox and control-plane actions to specific principals.
    • Backward Compatibility: A default workspace is maintained for single-player deployments.
  3. Overview of openshell-prover

    main
    openshell-prover is a formal verifier for OpenShell sandbox policies. It encodes a policy, its attached credential set, and a binary capability registry into a Z3 SMT model to perform reachability queries. It is primarily used by the OpenShell gateway to automate the approval of agent-authored policy proposals. Any finding generated by the prover blocks auto-approval, whereas an empty delta allows the proposal to pass (provided the reviewer has enabled proposal_approval_mode).
  4. Overview of NVIDIA OpenShell

    main
    NVIDIA OpenShell is an open-source runtime designed for executing autonomous AI agents in sandboxed environments with kernel-level isolation. It allows developers to run agents with high capability (reading files, installing packages, calling APIs) while enforcing explicit security controls via declarative YAML policies. This prevents risks such as data exfiltration, credential theft, and unauthorized API usage.
  5. Overview of Gateway Interceptors

    main

    Gateway Interceptors are a first-class extension system in OpenShell designed to allow operators and external integrators to customize gateway API behavior. They enable the observation, modification, validation, rejection, or auditing of gateway operations at well-defined phases.

    Key Use Cases:

    • Enforcing tenancy and quotas (e.g., limiting the number of running sandboxes per user).
    • Enforcing naming conventions.
    • Verifying policy writes against an external authority.
    • Syncing policies and providers from an external source of truth.
    • Restricting driver configuration payloads to approved schemas or fixed values.

    Distinction from Drivers:

    • Drivers: Provide or replace platform-specific implementations (e.g., how sandboxes are provisioned on Docker, Kubernetes, or VMs).
    • Gateway Interceptors: Provide gateway-level governance and business logic around API operations (e.g., tenancy, quotas, and policy authority).
  6. Overview of Agent-Driven Policy Management (RFC 0002)

    main

    RFC 0002 proposes evolving OpenShell's Policy Advisor into an agent-native workflow. Instead of manual operator intervention, agents can inspect sandbox policies, draft narrow policy changes, and submit them for human review.

    Key Capabilities:

    • Agent Inspection: Agents can use local APIs to understand current sandbox constraints.
    • Automated Drafting: Agents generate narrow, valid policy changes based on observed denials.
    • Review Workflow: Proposals are submitted to a developer 'inbox' (accessible via TUI, CLI, or SDK) for approval.
    • Hot-Reloading: Approved updates are applied to the sandbox without requiring a restart.

    Safety Model:

    • Analysis occurs on the sandbox side.
    • Validation and persistence occur on the gateway side.
    • Explicit approval boundaries are maintained; agents cannot self-approve or unilaterally apply changes.
  7. Overview of the OpenShell Gateway API Surface

    main

    The OpenShell Gateway API is structured around platform objects and operational streams. It provides interfaces for managing the lifecycle of sandboxes, interacting with infrastructure providers, managing security policies, configuring inference settings, and handling observability data. All domain objects include shared metadata such as stable server-generated IDs, human-readable names, creation timestamps, and labels.

    | Area | Examples |
    |---|---|
    | Sandbox lifecycle | Create, list, delete, watch, exec, SSH session bootstrap, ForwardTcp service forwarding. |
    | Providers | Store provider records, discover credentials, resolve runtime environment. |
    | Policy and settings | Get effective sandbox config, update sandbox policy, manage global settings. |
    | Inference | Set gateway-level model/provider config and resolve sandbox route bundles. |
    | Observability | Push sandbox logs, stream sandbox status and logs to clients. |
  8. Understand the Gateway Persistence Layer

    main

    The OpenShell gateway uses a protobuf object store for persistence. Domain services store typed protobuf messages as opaque binary payloads, while the database maintains indexed metadata for lookup, versioning, and workflow state.

    Supported Backends:

    • SQLite: The default local store. The adapter automatically sets file permissions to 0o600 for security.
    • Postgres: Supported for high-availability (HA) deployments requiring external databases or multi-replica coordination.

    Core Schema Columns:

    • id: Stable gateway-generated primary key.
    • object_type: Logical resource kind (e.g., sandbox, provider, ssh_session, inference_route, sandbox_policy).
    • name: Unique human-readable name within an object type.
    • resource_version: Monotonically increasing counter used for Optimistic Concurrency Control (CAS).
    • payload: The Prost-encoded protobuf payload.
    • labels: JSON object for Kubernetes-style filtering.
    • scope & version: Used for scoped/versioned records like policy revisions.
  9. Understand the OpenShell Gateway responsibilities

    main

    The Gateway serves as the OpenShell control plane. Its primary functions include:

    • API Serving: Exposes gRPC APIs for sandbox lifecycle, provider management, policy updates, settings, inference configuration, logs, watch streams, and relay forwarding. It also serves HTTP endpoints for health, WebSocket tunnels, and edge-auth flows.
    • Authentication: Authenticates clients (CLI, SDK, TUI) and sandbox callbacks.
    • State Management: Persists platform state in SQLite or Postgres and manages provider credentials and inference configuration.
    • Workload Coordination: Instructs compute runtimes (Docker, Kubernetes, etc.) to create or delete sandbox workloads and coordinates supervisor relay sessions (connect, exec, file sync, service forwarding).

    Note: The gateway does not enforce agent network policy at request time; enforcement occurs inside the sandbox via the supervisor and proxy.

  10. Select a Compute Runtime for Sandbox Workloads

    main

    OpenShell supports several compute runtimes to manage sandbox workloads. Choose a runtime based on your deployment environment:

    • Docker: Best for local development. Uses host networking so loopback gateway endpoints work from the supervisor.
    • Podman: Best for rootless or single-machine deployments. Uses the Podman REST API, OCI image volumes, and CDI GPU devices.
    • Kubernetes: Best for cluster deployments via Helm. Uses Kubernetes API objects, service accounts, secrets, and PVC-backed storage.
    • VM: Experimental microVM isolation using libkrun. Each sandbox runs in a per-sandbox VM with a cached rootfs.ext4 and a writable overlay.ext4.
    • Extension: For out-of-tree drivers. Allows using custom drivers operated alongside the gateway via a Unix Domain Socket (UDS).
  11. Understand OpenShell System Roles

    main

    OpenShell uses a three-tier user role model to manage access across different scopes. Roles are assigned either via global OIDC claims or internal workspace membership records.

    RoleDescription
    Platform AdminA runtime role with full visibility across all workspaces. They create workspaces, assign Workspace Admins, and set gateway-wide default policies.
    Workspace AdminManages users, providers, policies, and quotas within a single workspace. They cannot change gateway infrastructure or access other workspaces.
    UserThe default role for OIDC-authenticated principals (human or machine). Users can create sandboxes and access all sandboxes within their assigned workspaces using the credentials available in those workspaces.
  12. Understand Supervisor Middleware and Egress Hooks

    main

    Supervisor middleware is an extension system that allows you to inspect, transform, block, and annotate supervisor-managed operations at specific phases.

    The first implementation is supervisor egress middleware, which targets outbound sandbox HTTP requests. This allows you to control the content of requests (e.g., redacting PII or blocking sensitive documents) rather than just the destination.

    Key capabilities include:

    • Inspection: Checking request content for sensitive data.
    • Transformation: Replacing content (e.g., redacting an image with a placeholder) or mutating headers.
    • Blocking: Using an allow/deny decision to short-circuit requests.
    • Annotation: Emitting structured findings (for auditing) and string metadata (for request-local context).