Skip to content

Models

The payloads of the daemon API, as Pydantic models: field names are those of docker-sandbox, unknown fields of a newer daemon are kept (extra="allow"), and request models have the constructors of the library as class methods. A few models keep only their own fields: the items of a creation stream (CreateProgress, CreateResult, CreateFailure, CreateUnknown, which holds an unknown line whole), the output of an interactive session (OutputChunk, AttachOutput) and the images of a kit package (PackageImage). Every model is imported from fastsandbox.models; the most used are also exported by fastsandbox itself.

Sandboxes

Creation requests, their progress and result, the state of a sandbox, mounts and ports.

fastsandbox.models.Created

Bases: Model

Outcome of a successful creation.

Attributes:

Name Type Description
id str

Identifier assigned by the daemon.

name str

Sandbox name.

agent str

Agent of the base kit.

status str

Runtime state right after creation.

workspace str

Workspace directory, empty when there is none.

mcp McpGateway | None

MCP gateway of the sandbox.

withheld list[str]

Services whose credential, declared by a kit of the sandbox, the daemon does not authorize: the proxy injects nothing for them. Empty when the kits declare no credential or every one is authorized.

fastsandbox.models.CreateEvent module-attribute

CreateEvent = Annotated[CreateProgress | CreateResult | CreateFailure | CreateUnknown, Field(discriminator='type')]

An item of the progress stream of a creation.

fastsandbox.models.CreateFailure

Bases: BaseModel

The failure of a creation, the last item of a failed stream.

Attributes:

Name Type Description
message str

Why the creation failed.

fastsandbox.models.parse_create_event

parse_create_event(line: str) -> CreateEvent | None

The creation event of one line of the stream of a creation, or None for a blank line.

The daemon streams a creation as JSON lines: progress, then the result or the failure. A program that relays the stream of the daemon itself reads its lines with this function, as Sandboxes.create_stream does; a failure is a line, the daemon answering HTTP 200.

Example

event = parse_create_event('{"error": "image is not cached locally"}') (event.type, event.message) ('error', 'image is not cached locally')

Raises:

Type Description
ProtocolError

For a line that is not JSON, or a result line that describes no sandbox.

fastsandbox.models.CreateProgress

Bases: BaseModel

A progress line of a creation.

Attributes:

Name Type Description
message str

What the daemon is doing, e.g. assembled kit image ready.

fastsandbox.models.CreateRequest

Bases: Model

The creation request of a sandbox.

A kit package gives the request of its kit (KitPackage.request); adjust it with model_copy(update=…) or the with_* methods.

Attributes:

Name Type Description
name str

Sandbox name.

agent str

Agent of the base kit, e.g. shell.

kits list[str]

Kit references, base kit first.

kit_artifacts list[Any]

Resolved kit artifacts, one per kit; opaque.

pull_policy PullPolicy | None

When to pull kit images.

template str | None

Image the sandbox starts from instead of the image of its agent, such as one saved with Sandbox.save.

cpus int | None

Number of virtual CPUs.

memory str | None

Memory limit in sbx notation, e.g. 4g.

workspace str | None

Host directory bind-mounted as workspace, at the same path inside the sandbox.

additional_workspaces list[Workspace]

Further host directories or files to mount.

clone bool

Whether the agent works on a private clone of the Git repository of the workspace.

environment dict[str, str]

Environment variables of the sandbox.

ports list[PortBinding]

Ports published from the start.

skills SkillsMode | None

How the shared skills store reaches the sandbox.

profile str | None

Governance profile of the sandbox.

mcp Any

MCP gateway configuration, e.g. {"servers": [], "static": True}.

bindings_path str | None

Host file recording the credentials the user approved.

ssh_agent_socket_path str | None

Host SSH agent socket to forward.

enable_virtiofs_cache bool | None

Enables the virtio-fs cache for workspace mounts.

for_agent classmethod

for_agent(name: str, agent: str) -> CreateRequest

The creation request of the sandbox name for the agent agent, as a forger makes it.

It names no kit yet, and the images are pulled when missing: the forger sets kits and kit_artifacts, one artifact per kit, base kit first. The name {{name}} makes it the request of every sandbox of a kit package (KitPackage.in_memory).

with_workspace

with_workspace(dir: str) -> CreateRequest

The request, with dir of the host mounted as workspace.

with_cloned_workspace

with_cloned_workspace(repository: str) -> CreateRequest

The request, with the agent working on a private Git clone.

The clone is of the repository repository of the host.

with_additional_workspace

with_additional_workspace(workspace: Workspace) -> CreateRequest

The request, with one more mounted directory or file.

with_port

with_port(port: PortBinding) -> CreateRequest

The request, with one more port published from the start.

with_env

with_env(**variables: str) -> CreateRequest

The request, with more environment variables.

with_proxied_key

with_proxied_key(key: ProxiedKey) -> CreateRequest

The request, with the placeholder of key in the variable it names.

The key itself goes with Sandbox.push_proxied_keys, once the sandbox exists.

with_static_mcp_servers

with_static_mcp_servers(*servers: str) -> CreateRequest

The request, with an MCP gateway fixed to servers.

fastsandbox.models.CreateResult

Bases: BaseModel

The outcome of a creation, the last item of a successful stream.

Attributes:

Name Type Description
created Created

The sandbox created.

fastsandbox.models.CreateUnknown

Bases: BaseModel

A line of a creation stream the library does not know.

Attributes:

Name Type Description
raw Any

The line, as the daemon sent it.

fastsandbox.models.HostMount

Bases: Model

A host directory mounted into a sandbox.

Attributes:

Name Type Description
host_path str

Directory on the host.

container_target str | None

Mount point inside the sandbox.

read_only bool

Whether the mount is read-only.

fastsandbox.models.PortBinding

Bases: Model

A port published from a sandbox to the host.

Attributes:

Name Type Description
sandbox_port int

Port inside the sandbox.

host_port int

Port on the host.

host_ip str | None

Address bound on the host; the daemon defaults to 127.0.0.1.

protocol str | None

Protocol, e.g. tcp, tcp4 or udp.

tcp classmethod

tcp(sandbox_port: int, host_port: int, host_ip: str | None = None) -> PortBinding

A TCP port.

udp classmethod

udp(sandbox_port: int, host_port: int, host_ip: str | None = None) -> PortBinding

A UDP port.

fastsandbox.models.PullPolicy

Bases: StrEnum

When kit images are pulled during creation.

fastsandbox.models.RuntimeMount

Bases: Model

A host path granted to a running sandbox.

Attributes:

Name Type Description
host_path str

Directory on the host.

fastsandbox.models.SandboxInfo

Bases: Model

A sandbox, as the daemon describes it.

Attributes:

Name Type Description
id str

Identifier assigned by the daemon; it guards deletion against a sandbox that took the same name.

name str

Sandbox name.

agent str

Agent of the base kit, e.g. shell or claude.

status str

Runtime state, e.g. running or stopped.

created_at str | None

Creation time (RFC 3339).

last_used_at str | None

Time of last use (RFC 3339).

workspace str

Host directory bind-mounted as workspace, empty when none.

working_dir str | None

Working directory recorded for the sandbox.

effective_working_dir str | None

Working directory actually used inside it.

cpus int | None

Number of virtual CPUs, when set explicitly.

memory str | None

Memory limit, when set explicitly (sbx notation, e.g. 2g).

host_mounts list[HostMount]

Host directories mounted into the sandbox.

runtime_mounts list[RuntimeMount]

Host paths granted at run time.

ports list[PortBinding]

Published ports, in single-sandbox answers only.

labels dict[str, str]

Container labels set by sbx.

credential_sources dict[str, Any]

Service credentials configured, by service.

is_running property

is_running: bool

Whether the sandbox is running.

fastsandbox.models.SandboxState

Bases: StrEnum

The runtime states of a sandbox the library names.

The daemon may report others, kept as plain strings.

fastsandbox.models.SavedImage

Bases: Model

Image a sandbox was saved to.

Attributes:

Name Type Description
image_id str

Image identifier (sha256:…).

tag str

Fully qualified tag, e.g. docker.io/library/snap:v1.

fastsandbox.models.SkillsMode

Bases: StrEnum

How the shared skills store of the host reaches the sandbox.

fastsandbox.models.SwapOutcome

Bases: Model

Outcome of a container swap.

Attributes:

Name Type Description
committed_image_id str | None

Image the previous container was committed to.

container_id str | None

Identifier of the new container.

docker_name str | None

Name of the new container.

fastsandbox.models.SwapRequest

Bases: Model

A container swap: the complete kit list of the new container.

Attributes:

Name Type Description
docker_name_override str

Name of the replacement container.

kit_artifacts list[Any]

Resolved artifacts of the complete kit list; opaque.

kit_refs list[str]

References of the complete kit list, base kit first.

fastsandbox.models.Workspace

Bases: Model

A further host directory or file bind-mounted into a sandbox.

Attributes:

Name Type Description
dir str

Directory or file on the host, by its real absolute path.

read_only bool

Whether the sandbox can only read it.

target str | None

Absolute path inside the sandbox; the path of dir when unset.

Commands

Command specifications, their outputs and states, interactive sessions.

fastsandbox.models.AgentSessionSpec

Bases: Model

A session with the agent of the sandbox kit.

Attributes:

Name Type Description
args list[str]

Arguments of the agent, as sbx run AGENT -- ARGS passes them.

tty bool

Allocates a pseudo-terminal; agents generally expect one.

terminal_size TerminalSize | None

Initial terminal size, when tty is set.

working_dir str | None

Working directory; the sandbox's by default.

env dict[str, str]

Additional environment variables.

ssh_agent_socket_path str | None

Host SSH agent socket to forward.

fastsandbox.models.AttachOutput

Bases: BaseModel

Everything an interactive session wrote, collected until its exit.

Attributes:

Name Type Description
exit_code int

Exit code of the process.

stdout bytes

Standard output.

stderr bytes

Standard error.

ok property

ok: bool

Whether the command exited with code 0.

fastsandbox.models.AttachSpec

Bases: Model

An interactive command.

Attributes:

Name Type Description
cmd list[str]

Program and arguments, not interpreted by a shell.

user str | None

User name or UID ("0" for root).

working_dir str | None

Working directory.

env dict[str, str]

Additional environment variables.

tty bool

Allocates a pseudo-terminal; the output is then a single stream.

terminal_size TerminalSize | None

Initial terminal size, when tty is set.

shell classmethod

shell(script: str, **fields: Any) -> AttachSpec

A shell script, run with sh -c.

fastsandbox.models.ExecInspect

Bases: Model

State of an execution.

Attributes:

Name Type Description
id str

Execution identifier.

running bool

Whether the process is still running.

exit_code int | None

Exit code, once the process has exited.

fastsandbox.models.ExecOutput

Bases: Model

Result of a command run to completion.

Attributes:

Name Type Description
exit_code int

Exit code of the process.

stdout str

Standard output.

stderr str

Standard error.

ok property

ok: bool

Whether the command exited with code 0.

check

check() -> ExecOutput

The output itself, or CommandFailedError on a non-zero exit code.

fastsandbox.models.ExecSpec

Bases: Model

A command to run to completion inside a sandbox.

Attributes:

Name Type Description
cmd list[str]

Program and arguments, not interpreted by a shell.

user str | None

User name or UID ("0" for root); the kit's user by default.

working_dir str | None

Working directory; the kit's by default.

env dict[str, str]

Additional environment variables.

shell classmethod

shell(script: str, **fields: Any) -> ExecSpec

A shell script, run with sh -c.

fastsandbox.models.OutputChunk

Bases: BaseModel

A chunk of the output of an interactive session.

Attributes:

Name Type Description
stream Literal['stdout', 'stderr', 'other']

stdout or stderr; a TTY session writes everything to stdout. other for a stream a newer docker-sandbox adds.

data bytes

The bytes.

text property

text: str

The bytes decoded as UTF-8, invalid sequences replaced.

fastsandbox.models.TerminalSize

Bases: Model

Terminal dimensions, in characters.

Attributes:

Name Type Description
height int

Number of rows.

width int

Number of columns.

Credentials

Credentials pushed to a sandbox and the secrets of the daemon.

fastsandbox.models.CredentialSource

Bases: Model

How a service credential is resolved inside the sandbox.

Attributes:

Name Type Description
source str

Source identifier, e.g. an environment variable name.

kind str

Source kind, e.g. env.

env classmethod

env(name: str) -> CredentialSource

The environment variable name.

fastsandbox.models.CredentialsOutcome

Bases: Model

Outcome of a credentials update pushed to a sandbox.

The daemon accepts an update even when it withholds what it carries: read withheld to know which services get nothing.

Attributes:

Name Type Description
message str | None

Human-readable message, e.g. Credentials updated.

withheld list[str]

Services whose credential, declared by a kit of the sandbox, the daemon does not authorize: the proxy injects nothing for them, a value just pushed included.

credential_source_updates_applied bool | None

Whether the credential sources of the update were applied; None when the update carries none.

fastsandbox.models.CredentialsUpdate

Bases: Model

An update of the credentials of a sandbox.

Attributes:

Name Type Description
custom_secrets list[CustomSecret] | None

Proxy-injected secrets: None leaves those of the sandbox as they are, a list replaces them.

credential_values list[ServiceCredential]

Credentials for services known to sbx.

credential_sources dict[str, CredentialSource]

How each service credential is resolved.

removed_credential_sources list[str]

Services whose source is removed.

with_custom_secret

with_custom_secret(secret: CustomSecret) -> CredentialsUpdate

The update, with one more custom secret.

without_custom_secrets

without_custom_secrets() -> CredentialsUpdate

The update, removing every custom secret of the sandbox.

with_service_credential

with_service_credential(service: str, value: str | SecretStr) -> CredentialsUpdate

The update, with the credential of service, given as text or as a SecretStr.

with_credential_source

with_credential_source(service: str, source: CredentialSource) -> CredentialsUpdate

The update, resolving the credential of service from source.

without_credential_source

without_credential_source(service: str) -> CredentialsUpdate

The update, removing the source of service.

with_sandbox_secret

with_sandbox_secret(sandbox: str, service: str, value: str) -> CredentialsUpdate

The update, storing value as the sandbox secret of service.

As sbx secret set does, for the sandbox sandbox.

without_sandbox_secret

without_sandbox_secret(service: str) -> CredentialsUpdate

The update, removing the stored secret of service.

fastsandbox.models.CustomSecret

Bases: Model

A secret the sandbox proxy injects into requests to targets.

The sandbox only sees the placeholder sentinel.

Attributes:

Name Type Description
env_name str | None

Environment variable the placeholder is meant for, recorded with the secret; the daemon sets no such variable in the sandbox, its creation request does (CreateRequest.with_env, or with_proxied_key for a ProxiedKey).

sentinel str

Placeholder visible inside the sandbox.

target str

Primary target host.

targets list[str]

Every host or pattern the real value is sent to.

value SecretStr

The real value, never printed.

new classmethod

new(targets: list[str], sentinel: str, value: str | SecretStr, env_name: str | None = None) -> CustomSecret

A secret for targets, the first being the primary one.

value may be a pydantic.SecretStr the program already holds: it is passed on as it is, never exposed in between.

fastsandbox.models.ServiceCredential

Bases: Model

A credential for a service known to sbx.

Attributes:

Name Type Description
service str

Service identifier, e.g. github.

value SecretStr

The credential, never printed; empty to clear it.

cleared classmethod

cleared(service: str) -> ServiceCredential

Clears the credential of service.

Network policy

Rules, checks and the activity log of the network policy.

fastsandbox.models.CheckKind

Bases: StrEnum

Kind of a network check.

fastsandbox.models.CheckResult

Bases: Model

Decision of the policy for a network check.

Attributes:

Name Type Description
allowed bool

Whether the target is allowed.

rule str | None

Rule that decided.

action str | None

Action checked, e.g. net:connect:tcp.

resource_type str | None

Kind of resource matched, e.g. net:domain.

resource_value str | None

Resource matched, e.g. api.anthropic.com:443.

target str | None

Normalized target.

context str | None

Scope of the decision, e.g. global.

governance Any

Organization governance state.

fastsandbox.models.CreatedRule

Bases: Model

A rule created by a rule change.

Attributes:

Name Type Description
rule_id str

Identifier of the new rule.

resource str

Resource the rule covers.

protocols list[str]

Protocols of the rule.

fastsandbox.models.Decision

Bases: StrEnum

The outcomes of a rule the library names; others are plain strings.

fastsandbox.models.HostActivity

Bases: Model

Traffic of one sandbox to one host.

Attributes:

Name Type Description
host str

Host and port, e.g. api.anthropic.com:443.

vm_name str | None

Sandbox the traffic came from.

count_since int

Number of connections since since.

since str | None

Start of the count (RFC 3339).

last_seen str | None

Last connection (RFC 3339).

proxy_type str | None

How the proxy handled the traffic, e.g. forward.

rule str | None

Rule that decided, when one did.

reason str | None

Why the traffic was blocked, for a blocked host.

fastsandbox.models.HttpTarget

Bases: Model

Host and path of an HTTP rule.

Attributes:

Name Type Description
host str

Host.

path str | None

Path pattern, e.g. /v1/**.

fastsandbox.models.NetworkCheck

Bases: Model

A target to check against the network policy.

Attributes:

Name Type Description
kind CheckKind

Kind of target.

target str

Host, host:port or URL.

method str | None

HTTP method of an HTTP check.

host classmethod

host(target: str) -> NetworkCheck

A connection to target, a host or host:port.

http classmethod

http(method: str, url: str) -> NetworkCheck

An HTTP request method to url.

fastsandbox.models.NetworkLog

Bases: Model

Hosts the sandboxes reached or were refused.

Attributes:

Name Type Description
allowed_hosts list[HostActivity]

Hosts that were allowed.

blocked_hosts list[HostActivity]

Hosts that were blocked.

for_sandbox

for_sandbox(name: str) -> NetworkLog

The traffic of the sandbox name only.

fastsandbox.models.NetworkRule

Bases: Model

A rule of the policy: network, HTTP or file system access.

Attributes:

Name Type Description
id str

Rule identifier.

name str

Rule name, the identifier for added rules.

decision str

allow, deny or another decision of the daemon.

actions list[str]

Actions the rule governs, e.g. net:connect:tcp.

resources list[str]

Hosts or patterns it applies to; ** matches everything.

resource_type str | None

Kind of resource: network, http, filesystem:read, …

scope str | None

global, or sandbox:<name> for a sandbox-scoped rule.

applies_to str | None

What the rule applies to: all, or sandbox:<name>.

sandbox_id str | None

Sandbox of a sandbox-scoped rule.

methods list[str]

HTTP methods of an HTTP rule.

http_targets list[HttpTarget]

Hosts and paths of an HTTP rule.

editable bool

Whether the rule can be changed or removed.

origin str | None

Where the rule comes from: local, scoped, …

layer str | None

Policy layer of the rule.

policy_id str | None

Policy the rule belongs to.

status str | None

Rule state, e.g. active.

provenance Any

How the rule was created.

is_for_sandbox

is_for_sandbox(name: str) -> bool

Whether the rule is scoped to the sandbox name.

fastsandbox.models.NetworkRules

Bases: Model

The rules in force.

Attributes:

Name Type Description
governance_active bool

Whether an organization policy governs the rules.

rules list[NetworkRule]

Every rule, global and sandbox-scoped.

fastsandbox.models.Protocol

Bases: StrEnum

Transport protocol of a network rule.

fastsandbox.models.RuleAction

Bases: StrEnum

What a rule change does.

fastsandbox.models.RuleChange

Bases: Model

A change to the network rules.

Build one with the class methods, then scope it with for_sandbox.

Attributes:

Name Type Description
action RuleAction

What the change does.

resources list[str]

Hosts or patterns it applies to.

id str | None

Rule removed by remove_rule.

protocols list[Protocol]

Protocols of an allow or deny rule.

methods list[str]

HTTP methods of an HTTP rule.

path str | None

Path pattern of an HTTP rule.

sandbox_id str | None

Sandbox the change is scoped to; global when unset.

allow classmethod

allow(*resources: str) -> RuleChange

Allows TCP connections to the hosts or patterns.

deny classmethod

deny(*resources: str) -> RuleChange

Denies TCP and UDP connections to the hosts or patterns.

allow_http classmethod

allow_http(*resources: str) -> RuleChange

Allows HTTP requests to the hosts or patterns, on every path (/**).

with_path narrows the path, with_methods names the methods.

deny_http classmethod

deny_http(*resources: str) -> RuleChange

Denies HTTP requests to the hosts or patterns, on every path (/**).

with_path narrows the path, with_methods names the methods.

remove classmethod

remove(*resources: str) -> RuleChange

Removes the rules added for the resources.

remove_rule classmethod

remove_rule(id: str) -> RuleChange

Removes the rule id.

for_sandbox

for_sandbox(name: str) -> RuleChange

The change, scoped to the sandbox name.

with_protocols

with_protocols(*protocols: Protocol | str) -> RuleChange

The change, for the given protocols.

with_methods

with_methods(*methods: str) -> RuleChange

The HTTP change, for the given methods.

with_path

with_path(path: str) -> RuleChange

The HTTP change, for the given path pattern.

fastsandbox.models.HostPattern

Bases: str

A host a network rule names, checked as the CLI checks it: the text itself, as a str.

The forms the CLI accepts:

  • an exact domain, example.com, with globs inside its labels: ? for one character, [12] or [!1] for a class;
  • leading wildcard labels: *.example.com for one label, **.example.com for any number;
  • an IPv4 address, or a CIDR prefix, 10.0.0.0/8 or 2001:db8::1/128;
  • any of those with a port, example.com:443; an IPv6 address takes its port in brackets, [2001:db8::1]:443;
  • **, every host.

HostPattern(text), or HostPattern.parse(text), checks the text without the daemon, as a program checks the hosts it is given before it writes a rule.

Example

HostPattern(".githubusercontent.com") '.githubusercontent.com' HostPattern("https://api.github.com") Traceback (most recent call last): ... InvalidHostPatternError: invalid host pattern "https://api.github.com": a host, not a URL...

Raises:

Type Description
InvalidHostPatternError

For a text in none of those forms: empty, with spaces, a URL, a path, a bare *, an escaped glob character, a bare IPv6 address, a port that is not one; its reason says why.

parse classmethod

parse(pattern: str) -> HostPattern

The host pattern pattern; see HostPattern.

fastsandbox.models.RuleChangeResult

Bases: Model

Outcome of one rule change.

Attributes:

Name Type Description
action str

Action that was applied, as the daemon names it.

error str | None

Why the change failed, e.g. an unknown rule identifier.

id str | None

Rule identifier of a removal by identifier.

resources list[str]

Resources it was applied to.

sandbox_id str | None

Sandbox it was scoped to.

created list[CreatedRule]

Rules created by the change.

is_applied property

is_applied: bool

Whether the change applied.

check

check() -> RuleChangeResult

The result itself, or OperationFailedError when it did not apply.

Images

Images of the daemon and the progress of a pull.

fastsandbox.models.ImageInspect

Bases: Model

Details of an image.

Attributes:

Name Type Description
id str

Image identifier (sha256:…).

agent str | None

Agent of the kit the image belongs to, when known.

cmd list[str]

Default command.

entrypoint list[str]

Entrypoint.

user str | None

Default user.

created_at str | None

Creation time (RFC 3339).

fastsandbox.models.ImageSummary

Bases: Model

An image of the daemon.

Attributes:

Name Type Description
repository str

Repository, e.g. docker.io/library/sandbox-kit-assembled.

tag str | None

Tag, absent for images only referenced by digest.

id str

Image identifier (sha256:…).

digest str | None

Content digest (sha256:…).

size int | None

Size in bytes.

created_at str | None

Creation time (RFC 3339).

agent str | None

Agent of the kit the image belongs to, when known.

reference property

reference: str

repository:tag, else repository@digest, else repository@id.

fastsandbox.models.LocalImageMetadata

Bases: Model

Local metadata of an image.

Attributes:

Name Type Description
local_snapshot bool

Whether the image is a locally saved snapshot.

fastsandbox.models.ProgressDetail

Bases: Model

Byte counts of a layer being pulled.

Attributes:

Name Type Description
current int | None

Bytes transferred so far.

total int | None

Size of the layer.

fastsandbox.models.PullProgress

Bases: Model

One line of the progress of an image pull.

Attributes:

Name Type Description
id str | None

Layer the line refers to, when it refers to one.

status str | None

What happens, e.g. Downloading.

progress_detail ProgressDetail | None

Byte counts of the layer.

error str | None

Failure of the pull, always the last line of a failed stream.

MCP

The MCP gateway and the servers registered with it.

fastsandbox.models.GatewayMode

Bases: Model

Gateway mode of the daemon.

Attributes:

Name Type Description
decision str

Gateway in use, e.g. local.

gateway_url str | None

URL of a remote gateway, none for the local one.

reason str | None

Why this gateway is used.

fastsandbox.models.LoadedServer

Bases: Model

A server loaded into the gateway of a sandbox.

Attributes:

Name Type Description
sandbox str

Sandbox name.

server str

Server name.

fastsandbox.models.McpGateway

Bases: Model

MCP gateway of a sandbox.

Attributes:

Name Type Description
state str | None

Gateway state, e.g. ready.

url str | None

Gateway URL as seen from inside the sandbox.

port int | None

Port of the gateway on the host.

static_servers bool

Whether the set of servers was fixed at creation.

servers list[str]

Servers loaded into the gateway.

fastsandbox.models.McpServerCheck

Bases: Model

An MCP server to check against the MCP policy.

Attributes:

Name Type Description
name str

Server name.

kind McpServerKind

Where the server runs.

command list[str]

Program and arguments of a local server.

url str | None

URL of a remote server.

local classmethod

local(name: str, command: list[str]) -> McpServerCheck

A server started on the host by command.

remote classmethod

remote(name: str, url: str) -> McpServerCheck

A server reached at url.

fastsandbox.models.McpServerKind

Bases: StrEnum

Where an MCP server runs.

fastsandbox.models.RegistrationCheck

Bases: Model

Decision of the policy for an MCP server.

Attributes:

Name Type Description
allowed bool

Whether the server may be registered.

name str

Server name.

Daemon

Health, information, settings and disk usage of the daemon.

fastsandbox.models.DaemonInfo

Bases: Model

What the daemon says of itself: the path of the API socket it serves.

Its version is in its health (Health); a field a newer daemon adds is kept.

Attributes:

Name Type Description
api_socket str | None

Path of the API socket served by the daemon.

fastsandbox.models.DiskUsage

Bases: Model

Disk usage of images, containers and volumes.

Attributes:

Name Type Description
summaries list[DiskUsageSummary]

Totals per resource type.

images list[Any]

Per-image details, as reported by the daemon.

containers list[Any]

Per-container details.

volumes list[Any]

Per-volume details.

fastsandbox.models.DiskUsageSummary

Bases: Model

Disk usage totals for one resource type.

Attributes:

Name Type Description
resource_type str

Resource type, e.g. Images, Containers.

total_count int

Number of resources.

active int

Number of resources in use.

size int

Total size in bytes.

reclaimable int

Size that could be reclaimed, in bytes.

fastsandbox.models.Health

Bases: Model

Health of the daemon.

Attributes:

Name Type Description
status str

Overall status, healthy when the daemon is operational.

version str

Release version, e.g. v0.54.1.

api_version str

Version of the daemon API, e.g. 0.52.0.

revision str | None

Source revision of the release.

release bool | None

Whether this is a release build.

is_healthy property

is_healthy: bool

Whether the daemon reports itself operational.

fastsandbox.models.Setting

Bases: Model

A daemon setting.

Attributes:

Name Type Description
key str

Setting key, e.g. sandbox.disk.dockerVolume.

value Any

Effective value.

default Any

Default value.

source str | None

Where the effective value comes from: default, override, …

value_type str | None

Value type: bool, string, int, …

description str | None

Human-readable description.

Events

The events of the daemon.

fastsandbox.models.DaemonEvent

Bases: Model

An event published by the daemon.

Attributes:

Name Type Description
id str

Unique event identifier.

event_type str

Event family, e.g. sandbox.lifecycle.

action str

What happened, e.g. created, started, published.

timestamp str | None

Emission time (RFC 3339).

sandbox_name str | None

Sandbox the event refers to, if any.

sandbox_id str | None

Identifier of that sandbox, if any.

seq int | None

Per-sandbox sequence number, if any.

data Any

Event-specific payload.

kind property

kind: EventKind

The family of the event.

is_sync property

is_sync: bool

Whether this event marks the end of the initial replay.

is_about

is_about(name: str) -> bool

Whether the event refers to the sandbox name.

fastsandbox.models.EventKind

Bases: Enum

The families of daemon events the library tells apart.

Prompts

The approval prompts of the daemon.

fastsandbox.models.PromptEvent

Bases: Model

One line of the prompt stream; every field but action and id is kept as an extra field.

Attributes:

Name Type Description
action str | None

What happened, e.g. synced once the pending prompts are delivered.

id str | None

Identifier of the prompt, to answer it with.

is_synced property

is_synced: bool

Whether this line marks the end of the pending prompts.

Kits

What a kit package records.

fastsandbox.models.PackageImage

Bases: BaseModel

An image archive of a kit package.

The images a package lists (KitPackage.images) name their archive without holding it: KitPackage.image_archive(index) reads it. An image made with PackageImage.in_memory holds its archive, for a package assembled by hand (KitPackage.in_memory).

Attributes:

Name Type Description
path str | None

Path of the archive, None for an archive held in memory, as those of a package forged in memory are.

reference str | None

Reference the archive loads as, when known.

size int | None

Size of the archive in bytes, of the file or of the bytes held in memory, when known.

archive property

archive: bytes | None

The archive this image holds, made with in_memory; None for a listed image.

in_memory classmethod

in_memory(reference: str, archive: bytes) -> PackageImage

An image whose archive archive is held in memory, loaded under reference.

The daemon loads it under reference when it does not hold an image of that reference yet: an image it holds is not loaded again.

Sandbox specs

What a launch from a sandbox spec did.

fastsandbox.models.Report

Bases: Model

What a launch did. It never holds the value of a key or of a token.

Attributes:

Name Type Description
kits list[str]

The kits of the sandbox, by reference: its base kit, then its mixins, the generated ones included (/kits/docker-sandbox-network, /kits/docker-sandbox-mcp-<agent>).

network NetworkReport

The network rules of the spec.

keys list[KeyReport]

Where each key goes.

keys_left_out list[LeftOutKey]

The optional keys left out, and why.

mcp list[ServerReport]

The MCP servers registered in the agent.

withheld list[str]

The services whose credential, declared by a kit, the daemon withholds: the proxy injects nothing for them, the subscription of the agent included.

fastsandbox.models.NetworkReport

Bases: Model

The network rules of a launch.

Attributes:

Name Type Description
allow list[str]

The hosts the spec allows.

deny list[str]

The hosts the spec refuses.

http_allow list[HttpRuleReport]

The HTTP requests the spec allows.

http_deny list[HttpRuleReport]

The HTTP requests the spec refuses.

warning str | None

Why the allowances restrict nothing, when the global policy of the daemon allows every host, as it does under the Open preset of sbx: a refusal is what keeps a sandbox from a host.

fastsandbox.models.HttpRuleReport

Bases: Model

An HTTP rule of a launch: the hosts, methods and path it allows or refuses.

Attributes:

Name Type Description
hosts list[str]

The hosts of the rule, host patterns.

methods list[str]

Its methods, e.g. GET.

path str

Its path pattern, e.g. /v1/**.

fastsandbox.models.KeyReport

Bases: Model

Where a key of a launch goes.

Attributes:

Name Type Description
env str

The variable of the sandbox holding its placeholder.

hosts list[str]

The hosts the proxy writes it for.

fastsandbox.models.LeftOutKey

Bases: Model

An optional key a launch left out, never its value.

Attributes:

Name Type Description
env str

The variable of the key.

service str | None

The service of the key, if it names one.

reason LeftOutReason | str

Why it was left out.

fastsandbox.models.LeftOutReason

Bases: StrEnum

Why a launch left an optional key out.

NO_VALUE class-attribute instance-attribute

NO_VALUE = 'no_value'

The key was given no value at launch.

UNDECLARED_SERVICE class-attribute instance-attribute

UNDECLARED_SERVICE = 'undeclared_service'

No kit of the sandbox declares the service of the key.

fastsandbox.models.ServerReport

Bases: Model

An MCP server a launch registered in the agent.

Attributes:

Name Type Description
name str

The name the agent knows it under.

kind str

Its kind: host, remote or stdio.

agent str

The agent it is registered in.

Base

The base of every model and the helpers that give their wire shape.

fastsandbox.models.Model

Bases: BaseModel

Base of the payload models of the daemon.

Unknown fields are kept, and fields are settable by their name or their alias. The events of a creation, the chunks of an output and the images of a package are plain models, which drop unknown fields.

fastsandbox.models.expose_secret

expose_secret(value: SecretStr, info: SerializationInfo) -> str

A secret, exposed only for the native extension.

fastsandbox.models.wire

wire(model: BaseModel) -> Any

The JSON shape of a request model, as the native extension expects it.

Aliases are applied, unset optional fields left out, secrets exposed.