Skip to content

Data

Classes:

Name Description
BashAction
BashInterruptAction
BashObservation
CloseBashSessionRequest
CloseBashSessionResponse
CloseResponse
Command

A command to run as a subprocess.

CommandResponse
CreateBashSessionRequest
CreateBashSessionResponse
IsAliveResponse

Response to the is_alive request.

ReadFileRequest
ReadFileResponse
UploadRequest
UploadResponse
WriteFileRequest
WriteFileResponse

Attributes:

Name Type Description
Action

Union type for all actions. Do not use this directly.

CloseSessionRequest

Union type for all close session requests. Do not use this directly.

CloseSessionResponse

Union type for all close session responses. Do not use this directly.

CreateSessionRequest

Union type for all create session requests. Do not use this directly.

CreateSessionResponse

Union type for all create session responses. Do not use this directly.

Observation

Union type for all observations. Do not use this directly.

Action module-attribute

Action = Annotated[BashAction | BashInterruptAction, Field(discriminator='action_type')]

Union type for all actions. Do not use this directly.

CloseSessionRequest module-attribute

CloseSessionRequest = Annotated[CloseBashSessionRequest, Field(discriminator='session_type')]

Union type for all close session requests. Do not use this directly.

CloseSessionResponse module-attribute

CloseSessionResponse = Annotated[CloseBashSessionResponse, Field(discriminator='session_type')]

Union type for all close session responses. Do not use this directly.

CreateSessionRequest module-attribute

CreateSessionRequest = Annotated[CreateBashSessionRequest, Field(discriminator='session_type')]

Union type for all create session requests. Do not use this directly.

CreateSessionResponse module-attribute

CreateSessionResponse = Annotated[CreateBashSessionResponse, Field(discriminator='session_type')]

Union type for all create session responses. Do not use this directly.

Observation module-attribute

Observation = Annotated[BashObservation, Field(discriminator='session_type')]

Union type for all observations. Do not use this directly.

BashAction pydantic-model

Bases: BaseModel

Fields:

action_type pydantic-field

action_type: Literal['bash'] = 'bash'

Used for type discrimination. Do not change.

check pydantic-field

check: Literal['silent', 'raise', 'ignore'] = 'raise'

Whether to check for the exit code. If "silent", we will extract the exit code, but not raise any errors. If there is an error extracting the exit code, it will be set to None. If "raise", we will raise a NonZeroExitCodeError if the command has a non-zero exit code or if there is an error extracting the exit code. If "ignore", we will not attempt to extract the exit code, but always leave it as None.

command pydantic-field

command: str

The command to run.

error_msg pydantic-field

error_msg: str = ''

This error message will be used in the NonZeroExitCodeError if the command has a non-zero exit code and check is True.

expect pydantic-field

expect: list[str] = []

Outputs to expect in addition to the PS1

is_interactive_command pydantic-field

is_interactive_command: bool = False

For a non-exiting command to an interactive program (e.g., gdb), set this to True.

is_interactive_quit pydantic-field

is_interactive_quit: bool = False

This will disable checking for exit codes, since the command won't terminate. If the command is something like "quit" and should terminate the interactive program, set this to False.

session pydantic-field

session: str = 'default'

The session to run the command in.

timeout pydantic-field

timeout: float | None = None

The timeout for the command. None means no timeout.

BashInterruptAction pydantic-model

Bases: BaseModel

Fields:

action_type pydantic-field

action_type: Literal['bash_interrupt'] = 'bash_interrupt'

expect pydantic-field

expect: list[str] = []

Outputs to expect in addition to the PS1

n_retry pydantic-field

n_retry: int = 3

How many times to retry quitting.

session pydantic-field

session: str = 'default'

timeout pydantic-field

timeout: float = 0.2

The timeout for the command. None means no timeout.

BashObservation pydantic-model

Bases: BaseModel

Fields:

exit_code pydantic-field

exit_code: int | None = None

expect_string pydantic-field

expect_string: str = ''

Which of the expect strings was matched to terminate the command. Empty string if the command timed out etc.

failure_reason pydantic-field

failure_reason: str = ''

output pydantic-field

output: str = ''

session_type pydantic-field

session_type: Literal['bash'] = 'bash'

CloseBashSessionRequest pydantic-model

Bases: BaseModel

Fields:

session pydantic-field

session: str = 'default'

session_type pydantic-field

session_type: Literal['bash'] = 'bash'

CloseBashSessionResponse pydantic-model

Bases: BaseModel

Fields:

session_type pydantic-field

session_type: Literal['bash'] = 'bash'

CloseResponse pydantic-model

Bases: BaseModel

Command pydantic-model

Bases: BaseModel

A command to run as a subprocess.

Fields:

check pydantic-field

check: bool = False

Whether to check for the exit code. If True, we will raise a CommandFailedError if the command fails.

command pydantic-field

command: str | list[str]

The command to run. Should be a list of strings (recommended because of automatic escaping of spaces etc.) unless you set shell=True (i.e., exactly like with subprocess.run()).

cwd pydantic-field

cwd: str | None = None

The current working directory to run the command in.

env pydantic-field

env: dict[str, str] | None = None

Environment variables to pass to the command.

error_msg pydantic-field

error_msg: str = ''

This error message will be used in the NonZeroExitCodeError if the command has a non-zero exit code and check is True.

shell pydantic-field

shell: bool = False

Same as the subprocess.run() shell argument.

timeout pydantic-field

timeout: float | None = None

The timeout for the command. None means no timeout.

CommandResponse pydantic-model

Bases: BaseModel

Fields:

exit_code pydantic-field

exit_code: int | None = None

stderr pydantic-field

stderr: str = ''

stdout pydantic-field

stdout: str = ''

CreateBashSessionRequest pydantic-model

Bases: BaseModel

Fields:

session pydantic-field

session: str = 'default'

session_type pydantic-field

session_type: Literal['bash'] = 'bash'

startup_source pydantic-field

startup_source: list[str] = []

Source the following files before running commands. The reason this gets a special treatment is that these files often overwrite PS1, which we need to reset.

startup_timeout pydantic-field

startup_timeout: float = 1.0

The timeout for the startup commands.

CreateBashSessionResponse pydantic-model

Bases: BaseModel

Fields:

output pydantic-field

output: str = ''

Output from starting the session.

session_type pydantic-field

session_type: Literal['bash'] = 'bash'

IsAliveResponse pydantic-model

Bases: BaseModel

Response to the is_alive request.

You can test the result with bool().

Fields:

is_alive pydantic-field

is_alive: bool

message pydantic-field

message: str = ''

Error message if is_alive is False.

ReadFileRequest pydantic-model

Bases: BaseModel

Fields:

path pydantic-field

path: str

ReadFileResponse pydantic-model

Bases: BaseModel

Fields:

content pydantic-field

content: str = ''

UploadRequest pydantic-model

Bases: BaseModel

Fields:

source_path pydantic-field

source_path: str

target_path pydantic-field

target_path: str

UploadResponse pydantic-model

Bases: BaseModel

WriteFileRequest pydantic-model

Bases: BaseModel

Fields:

content pydantic-field

content: str

path pydantic-field

path: str

WriteFileResponse pydantic-model

Bases: BaseModel