AgentSessionManager.Workspace.Exec (AgentSessionManager v0.8.0)

Copy Markdown View Source

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.

Summary

Types

exec_opts()

@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() -> any())
]

exec_result()

@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()

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

Functions

run(command, args \\ [], opts \\ [])

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

run_streaming(command, args \\ [], opts \\ [])

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