AttractorEx.Agent.ExecutionEnvironment behaviour (attractor_phoenix v0.1.0)

Copy Markdown View Source

Execution-environment behaviour for coding-agent sessions.

The contract intentionally mirrors the core local tooling surface exposed by the agent loop: filesystem reads and writes, directory listing and globbing, text search, shell command execution, and a small amount of host metadata.

Summary

Callbacks

environment_context(term)

@callback environment_context(term()) :: map()

glob(term, t)

@callback glob(term(), String.t()) :: {:ok, [String.t()]} | {:error, term()}

grep(term, t, keyword)

@callback grep(term(), String.t(), keyword()) :: {:ok, [map()]} | {:error, term()}

list_directory(term, t)

@callback list_directory(term(), String.t()) :: {:ok, [map()]} | {:error, term()}

platform(term)

@callback platform(term()) :: String.t()

read_file(term, t)

@callback read_file(term(), String.t()) :: {:ok, String.t()} | {:error, term()}

shell_command(term, t, keyword)

@callback shell_command(term(), String.t(), keyword()) ::
  {:ok, %{output: String.t(), exit_code: integer(), truncated?: boolean()}}
  | {:error, term()}

working_directory(term)

@callback working_directory(term()) :: String.t()

write_file(term, t, t)

@callback write_file(term(), String.t(), String.t()) :: :ok | {:error, term()}

Functions

environment_context(env)

@spec environment_context(term()) :: map()

glob(env, pattern)

@spec glob(term(), String.t()) :: {:ok, [String.t()]} | {:error, term()}

grep(env, pattern, opts)

@spec grep(term(), String.t(), keyword()) :: {:ok, [map()]} | {:error, term()}

implementation?(env)

@spec implementation?(term()) :: boolean()

list_directory(env, path)

@spec list_directory(term(), String.t()) :: {:ok, [map()]} | {:error, term()}

platform(env)

@spec platform(term()) :: String.t()

read_file(env, path)

@spec read_file(term(), String.t()) :: {:ok, String.t()} | {:error, term()}

shell_command(env, command, opts)

@spec shell_command(term(), String.t(), keyword()) ::
  {:ok, %{output: String.t(), exit_code: integer(), truncated?: boolean()}}
  | {:error, term()}

working_directory(env)

@spec working_directory(term()) :: String.t()

write_file(env, path, content)

@spec write_file(term(), String.t(), String.t()) :: :ok | {:error, term()}