# `AgentSessionManager.Workspace.Exec`
[🔗](https://github.com/nshkrdotcom/agent_session_manager/blob/v0.8.0/lib/agent_session_manager/workspace/exec.ex#L1)

Low-level shell command execution with timeout, output capture, and cancellation.

This module provides direct command execution without session/run lifecycle
overhead. For managed execution with events and policies, use ShellAdapter.

# `exec_opts`

```elixir
@type exec_opts() :: [
  cwd: String.t(),
  timeout_ms: pos_integer(),
  max_output_bytes: pos_integer(),
  env: [{String.t(), String.t()}],
  shell: String.t(),
  on_output: (stream_chunk() -&gt; any())
]
```

# `exec_result`

```elixir
@type exec_result() :: %{
  command: String.t(),
  args: [String.t()],
  cwd: String.t(),
  exit_code: integer(),
  stdout: String.t(),
  stderr: String.t(),
  duration_ms: non_neg_integer(),
  timed_out: boolean()
}
```

# `stream_chunk`

```elixir
@type stream_chunk() ::
  {:stdout, binary()}
  | {:stderr, binary()}
  | {:exit, integer()}
  | {:error, term()}
```

# `run`

```elixir
@spec run(String.t(), [String.t()], exec_opts()) ::
  {:ok, exec_result()} | {:error, AgentSessionManager.Core.Error.t()}
```

# `run_streaming`

```elixir
@spec run_streaming(String.t(), [String.t()], exec_opts()) :: Enumerable.t()
```

---

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