orxtra v0.13.0 /tool.src.orxtra.tool._data_tool_monty
On this page

Builds a Tool from a MontyExecution definition: compiles the monty script once, wires capability host functions (read, write, edit, http, command, etc.) through the standard tool pipeline, and runs with resource limits.

#tool.src.orxtra.tool._data_tool_monty

#tool.src.orxtra.tool._data_tool_monty

Factory for building Tool instances from MontyExecution definitions.

Takes a DataToolDefinition with a MontyExecution config and builds a concrete Tool whose execute function:

  1. Validates agent-supplied args against the param schema.
  2. Compiles the monty code (once at factory time for efficiency).
  3. Builds capability host functions that invoke built-in tools

THROUGH THE PIPELINE (write queue, path scopes, safegit/saferm, scrubbing, tracing).

  1. Runs the script via monty.run_async with resource limits.
  2. Validates output against the definition's output schema (if any).
  3. Returns a ToolOutput with the validated data.

#derive_tags

python
def derive_tags(capabilities: list[str], user_tags: list[str] | None) -> frozenset[str]

Derive effect tags from granted capabilities.

If any capability is a mutation capability, the tool gets the "mutation" tag. If all are readonly, it gets "readonly".

#_build_read_capability

python
def _build_read_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the read capability: reads a file and returns its content.

#_build_write_capability

python
def _build_write_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the write capability: writes a file through write-safety.

#_build_edit_capability

python
def _build_edit_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the edit capability: find-and-replace through write-safety.

#_build_http_capability

python
def _build_http_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the http capability: makes HTTP requests.

#_build_command_capability

python
def _build_command_capability(definition: DataToolDefinition, deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the command capability: subprocess execution.

Uses the definition's CommandExecution config for the pinned executable and arg validation settings, backed by the relocated subprocess machinery.

#_build_list_dir_capability

python
def _build_list_dir_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the list_dir capability.

#_build_grep_capability

python
def _build_grep_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the grep capability.

#_build_glob_capability

python
def _build_glob_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the glob capability.

#_build_stat_capability

python
def _build_stat_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the stat capability.

#_build_diff_capability

python
def _build_diff_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the diff capability.

#_build_delete_capability

python
def _build_delete_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the delete capability.

#_build_move_capability

python
def _build_move_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the move capability.

#_build_copy_capability

python
def _build_copy_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the copy capability.

#_build_mkdir_capability

python
def _build_mkdir_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the mkdir capability.

#_build_set_executable_capability

python
def _build_set_executable_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the set_executable capability.

#_build_multi_edit_capability

python
def _build_multi_edit_capability(deps: ToolDeps) -> Callable[..., Coroutine[Any, Any, Any]]

Build the multi_edit capability.

#build_capability_functions

python
def build_capability_functions(capabilities: list[str], definition: DataToolDefinition, deps: ToolDeps) -> dict[str, Callable[..., Coroutine[Any, Any, Any]]]

Build the external function dict for monty from granted capabilities.

Each capability name maps to an async host function that invokes the corresponding built-in tool. Unrecognized capability names raise a hard error at construction time.

#build_monty_tool

python
def build_monty_tool(definition: DataToolDefinition, deps: ToolDeps) -> Tool

Build a Tool from a DataToolDefinition with MontyExecution config.

Args:

  • definition: A validated DataToolDefinition with type = "monty".
  • deps: Session-scoped dependencies for capability construction.

Returns:

  • A Tool instance ready for execution pipeline wrapping.

#build_command_tool

python
def build_command_tool(definition: DataToolDefinition, deps: ToolDeps) -> Tool

Build a Tool from a DataToolDefinition with CommandExecution config.

The command execution type is a thin wrapper around the relocated subprocess machinery. The definition specifies the pinned executable, arg validation, and timeout ceiling.

Args:

  • definition: A validated DataToolDefinition with type = "command".
  • deps: Session-scoped dependencies.

Returns:

  • A Tool instance ready for execution pipeline wrapping.
Search