Skip to content

Tool interface


ExecutionContext

Configuration for an execution of a tool.

command

command: list[str]

env_vars

env_vars: dict[str, str]

Tool

A tool is an external program that may require special handling to be executed properly.

app property

The Application instance.

execution_context abstractmethod

execution_context(
    command: list[str],
) -> Generator[ExecutionContext, None, None]

A context manager bound to the lifecycle of each tool execution.

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Yields:

Type Description
ExecutionContext

The execution context.

run

run(command: list[str], **kwargs: Any) -> int

Equivalent to SubprocessRunner.run with the tool's execution_context determining the final command and environment variables.

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.run.

capture

capture(command: list[str], **kwargs: Any) -> str

Equivalent to SubprocessRunner.capture with the tool's execution_context determining the final command and environment variables.

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.capture.

wait

wait(command: list[str], **kwargs: Any) -> None

Equivalent to SubprocessRunner.wait with the tool's execution_context determining the final command and environment variables.

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.wait.

exit_with

exit_with(command: list[str], **kwargs: Any) -> NoReturn

Equivalent to SubprocessRunner.exit_with with the tool's execution_context determining the final command and environment variables.

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.exit_with.

attach

attach(command: list[str], **kwargs: Any) -> CompletedProcess

Equivalent to SubprocessRunner.attach with the tool's execution_context determining the final command and environment variables.

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.attach.

redirect

redirect(command: list[str], **kwargs: Any) -> CompletedProcess

Equivalent to SubprocessRunner.redirect with the tool's execution_context determining the final command and environment variables.

Parameters:

Name Type Description Default
command list[str]

The command to execute.

required

Other Parameters:

Name Type Description
**kwargs Any

Additional keyword arguments to pass to SubprocessRunner.redirect.