# `H.Tool`
[🔗](https://github.com/parlant/harness/blob/v0.3.0/lib/h/tool.ex#L1)

Behaviour and JSON Schema validation helper for durable tools in `H`.

The coordinator binds the built-in coding tools' working directory before
acquiring a lease or calling `execute/2`. Workers use the bound `context.env`.
Read [Security boundaries on hiness.dev](https://hiness.dev/docs/security/)
before exposing host tools to external context.

# `context`

```elixir
@type context() :: %{
  :env =&gt; H.ExecutionEnv.t(),
  :session_id =&gt; String.t(),
  :conversation_id =&gt; pos_integer(),
  optional(:task_id) =&gt; pos_integer(),
  optional(:scan_entries) =&gt; (map() -&gt; {:ok, map()} | {:error, term()}),
  optional(:on_output) =&gt; (String.t(), non_neg_integer() -&gt; any()),
  optional(:timeout_ms) =&gt; pos_integer()
}
```

# `tool_output`

```elixir
@type tool_output() :: %{
  content: [map()],
  details: map(),
  is_error: boolean(),
  diagnostic: nil | String.t()
}
```

# `description`

```elixir
@callback description() :: String.t()
```

# `execute`

```elixir
@callback execute(args :: map(), context()) ::
  {:ok, tool_output()} | {:error, tool_output()}
```

# `mutating?`

```elixir
@callback mutating?() :: boolean()
```

# `name`

```elixir
@callback name() :: String.t()
```

# `parameters_schema`

```elixir
@callback parameters_schema() :: map()
```

# `replay`

```elixir
@callback replay() :: :safe | :unsafe
```

# `validate_args`

```elixir
@spec validate_args(module(), term()) :: {:ok, map()} | {:error, String.t()}
```

Validates decoded JSON tool arguments against `tool_mod.parameters_schema/0` via cached `JSV` root.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
