Skip to main content
See Customize the SDK for hook ordering, ownership, and implementation obligations. RunRequest describes one command. Executor contracts let adapters use a custom backend. Public command values and execution contracts for integrations.

class RunRequest

Command configuration passed through the session’s public extension hooks. Use dataclasses.replace to change a request. Arguments and environment are copied at construction. File sources and stdin remain caller-owned. Exactly one of command and shell must be supplied. Results are saved by default; use disposable=True to leave session history unchanged.

Attributes

str | None
str | None
tuple[str, ...]
Mapping[str, str] | None
str | None
str | bytes | Path | Readable[str] | Readable[bytes] | AsyncReadable[str] | AsyncReadable[bytes] | None
str | bytes | Path | Readable[str] | Readable[bytes] | AsyncReadable[str] | AsyncReadable[bytes] | None
bool
list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec] | None
list[str | Path | UploadFileSpec] | dict[str, str | Path | bytes | UploadFileSpec] | None
float | timedelta | None
bool
int | None
bool
str | None
int | None
int | None
InstanceResourcesLimits | None
InstanceNetworking | None
str
float | None

class OperationContext

The effective request and history position captured before remote execution.

Attributes

RunRequest
str
str
str | None
str | None
tuple[str, ...]
tuple[StagedFile, ...]
tuple[StagedFile, …]
bool
str
float
int
str | None
Mapping[str, str]

class SyncExecutor

Execution and file access required by synchronous framework adapters. Implementations own their lifecycle. Adapters do not close executors. Successful execution returns the client’s InstanceResult, including nonzero exit codes. read_file returns exact bytes or raises a client API exception.

Attributes

str

Methods

execute()

required
InstanceResult

read_file()

required
bytes

write_file()

Write bytes to an absolute path, creating its parent directories.Returns after the write is applied to the executor’s filesystem. It does not merely stage a file or upload a blob. Persistence follows execute(). The default runs mkdir and cat through execute() with binary stdin. Override this method to use another file-transfer mechanism. An override must coordinate with the executor’s commands and snapshot lifecycle.Invalid paths raise ValueError; a failed write raises FileWriteError. Transport errors, timeouts, and cancellation propagate unchanged.
required
required
None

class AsyncExecutor

Native asynchronous execution and file access for framework adapters.

Attributes

str

Methods

execute()

required
InstanceResult

read_file()

required
bytes

write_file()

Write bytes with the same contract as SyncExecutor.write_file.The default awaits execute() with binary stdin. Override with native async file transfer, coordinating with commands and snapshot lifecycle. Returns after application, not after staging or blob upload. Invalid paths raise ValueError; a failed write raises FileWriteError. Transport errors, timeouts, and cancellation propagate unchanged.
required
required
None
Public lifecycle contracts for operation and subprocess implementations.

class SubprocessContract

Waitable event stream for one subprocess. Iteration and wait share completion state.

Attributes

int

Methods

wait()

default:"None"
InstanceResult

pipe_to()

default:"None"
default:"None"
InstanceResult

class AsyncSubprocessContract

Waitable event stream for one subprocess. Iteration and wait share completion state.

Attributes

int

Methods

wait()

default:"None"
InstanceResult

pipe_to()

default:"None"
default:"None"
InstanceResult

class OperationContract

An operation lifecycle. wait stores response before returning; cleanup preserves primary errors.

Attributes

str
OperationContext | None
OperationResponse | None

Methods

add_observer()

Register an observer before starting the shared operation reader.A None event marks EOF, with an optional stream error. Observers must not consume events or wait for this operation. Implementations without this optional facility reject registration.
required
None

events()

default:"None"
default:"None"
default:"None"
Iterator[OperationEvent]

status()

default:"False"
OperationResponse

send_stdin()

required
default:"1"
default:"True"
None

pipe_stdin()

required
default:"1"
default:"True"
default:"65536"
StdinResult

signal()

default:"None"
default:"1"
None

cancel()

None

wait()

default:"None"
InstanceResult

run()

required
default:"False"
default:"()"
default:"None"
default:"None"
default:"None"
default:"None"
default:"None"
default:"False"
default:"None"
SubprocessContract

shutdown()

None

class AsyncOperationContract

An operation lifecycle. wait stores response before returning; cleanup preserves primary errors.

Attributes

str
OperationContext | None
OperationResponse | None

Methods

add_observer()

Register an observer before starting the shared operation reader.A None event marks EOF, with an optional stream error. Observers must not consume events or wait for this operation. Implementations without this optional facility reject registration.
required
None

events()

default:"None"
default:"None"
default:"None"
AsyncIterator[OperationEvent]

status()

default:"False"
OperationResponse

send_stdin()

required
default:"1"
default:"True"
None

pipe_stdin()

required
default:"1"
default:"True"
default:"65536"
StdinResult

signal()

default:"None"
default:"1"
None

cancel()

None

wait()

default:"None"
InstanceResult

run()

required
default:"False"
default:"()"
default:"None"
default:"None"
default:"None"
default:"None"
default:"None"
default:"False"
default:"None"
AsyncSubprocessContract

shutdown()

None